URAL 1981. Parallel and Perpendicular(数学 )

题目链接:?space=1&num=1981

You are given a regularn-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 integern(4 ≤n≤ 105).

Output

Output two required numbers.

Sample

inputoutput

40 2

题意:

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

PS:

画图即可看出规律,

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

代码如下:

#include <cstdio>#include <cmath>#define LL __int64int 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(数学 )

相关文章:

你感兴趣的文章:

标签云: