码迷,mamicode.com
首页 > 其他好文 > 详细

URAL 1981. Parallel and Perpendicular(数学 )

时间:2015-03-14 09:38:02      阅读:114      评论:0      收藏:0      [点我收藏+]

标签:数学   ural   

题目链接: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;
}


URAL 1981. Parallel and Perpendicular(数学 )

标签:数学   ural   

原文地址:http://blog.csdn.net/u012860063/article/details/44256631

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!