URAL 1981. Parallel and Perpendicular(数学 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1981

You are given a regular n-gon. Your task is to calculate two values: the number of its diagonals that are parallel to at least one of its other diagonals, and the number of its diagonals that
are perpendicular to at least one of its diagonals. A diagonal is a segment connecting two non-adjacent polygon vertices.

Input

The only line contains an integer n (4 ≤ n ≤ 105).

Output

Output two required numbers.

Sample

input output
4
0 2

题意:

求正多边形的对角线中 相互平行和相互垂直的条数!

PS:

画图即可看出规律,

1、边形偶数的都可以找到互相平行和垂直的

2、边形为奇数的不可能找到相互平行和垂直的

代码如下:

#include <cstdio>
#include <cmath>
#define LL __int64
int main()
{
    LL n;
    while(~scanf("%I64d",&n))
    {
        LL num = n*(n-3)/2;//对角线条数
        if(n == 4)
        {
            printf("0 2\n");
            continue;
        }
        if(n == 5)
        {
            printf("0 0\n");
            continue;
        }
        if(n == 6)
        {
            printf("6 9\n");
            continue;
        }
        if(n%2)//边形为奇数
        {
            printf("%I64d 0\n",num);//不可能有垂直的,画图就知道了
        }
        else//边形偶数的都可以找到互相平行和垂直的
        {
            printf("%I64d %I64d\n",num,num);
        }
    }
    return 0;
}
时间: 2024-12-16 15:54:18

URAL 1981. Parallel and Perpendicular(数学 )的相关文章

URAL 1617. Flat Spots(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1612 1617. Flat Spots Time limit: 0.5 second Memory limit: 64 MB Yekaterinburg has an extensive network of tram routes. Trams of more than ten routes go along some streets. It is clear that rails wear

URAL 1551. Sumo Tournament(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1551 1551. Sumo Tournament Time limit: 1.0 second Memory limit: 64 MB A sumo tournament is held in Tokyo, in which 2N sportsmen take part. In each encounter there is a winner, and the loser drops out

URAL 2070 Interesting Numbers(数学)

题目地址:http://acm.timus.ru/problem.aspx?space=1&num=2070 思路:质数一定满足题意(满足条件一,因子数为2为质数).所以只需求出l到r中的合数且因子数为质数的数的个数.该数质因子只能为1(若大于一,则因子数为合数),所以枚举每个质数,若该质数的指数+1(因子数)为质数,则ans--. #include<cstdio> #include<vector> #include<cstring> #include<i

URAL 1984. Dummy Guy(数学啊)

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1984 1984. Dummy Guy Time limit: 0.5 second Memory limit: 64 MB Every year students of our university participate in Regional Contest in Saint Petersburg. Train journeys from Yekaterinburg to Saint Pe

URAL 1885. Passenger Comfort(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1885 1885. Passenger Comfort Time limit: 1.0 second Memory limit: 64 MB Marketing managers of the company Oceanic Airlines started a new advertising campaign. Its aim was to emphasize the comfort of t

URAL 1889. Airport Announcements(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1889 1889. Airport Announcements Time limit: 1.0 second Memory limit: 64 MB Igor was bored of waiting in an airport lounge. Oceanic Airlines, a company he didn't like so much, delayed the departure of

URAL 1987. Nested Segments(数学 &amp; 线段树)

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1987 You are given n segments on a straight line. For each pair of segments it is known that they either have no common points or all points of one segment belong to the second segment. Then m queries

URAL 1823. Ideal Gas(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1823 1823. Ideal Gas Time limit: 0.5 second Memory limit: 64 MB Many of you know the universal method of solving simple physics problems: you have to find in a textbook an identity in which you know t

URAL 1725. Sold Out!(数学啊 )

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1725 Every fall, all movies are shown to a full house at one of the most popular cinema theatres in Yekaterinburg because students like to spend their time sitting in a cosy chair and watching a movie