URAL 1981. Parallel and Perpendicular 对角线的平行和垂直

1981. Parallel and Perpendicular

Time limit: 0.5 second
Memory limit: 64 MB
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 ≤ 10 5).

Output

Output two required numbers.

Sample

input output
4
0 2




题意:

问正n边形,有多少条对角线能找到一条以上与之平行的对角线,又有多少条对角线可以找到一条以上与之垂直的对角线。


 yy的。 画出了5,6,7,8,发现了点规律。正六边形 的三条线平分线是找不到与之平行的对角线的,而每一条线都可以找到与之垂直的对角线。所以n=6时,答案是6和9。再慢慢画出七边形,和五边形相似,没有对角线会互相垂直的,后面的所有奇数的正n边形都是找不到垂直的对角线的。但是奇数n>7,所有对角线都是可以找到互相平行的对角线的。再画画八边形,所有对角线都可以找到互相垂直互相平行的对角线。






#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <malloc.h>
#include <ctype.h>
#include <math.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#include <stack>
#include <queue>
#include <vector>
#include <deque>
#include <set>
#include <map>  
#include<stdio.h>
#include<stdlib.h>

#define pi acos(-1.0)
int main()
{  
	__int64 n,ans; 
	while(scanf("%I64d",&n) != EOF && n)  
	{   
		if(n==4)
		{
			puts("0 2");
		}
		else if(n==6)
			puts("6 9");
		else if (n&1)
		{
			if(n==5)
				puts("0 0");
			else
			{
				ans=(n*(n-3))/2; 
				printf("%I64d 0\n",ans); 
			}
		}
		else 
		{
			ans=(n*(n-3))/2;
			printf("%I64d %I64d\n",ans,ans); 
		}  
	} 
	return 0; 
}


你可能感兴趣的:(多边形,几何,对角线)