TOJ Open Ural FU Championship 2013 A
1981. Parallel and Perpendicular
Time limit: 0.5 second
Memory limit: 64 MB
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 ≤ 105).
Output
Output two required numbers.
Sample
| input | output |
|---|---|
4 |
0 2 |
Problem Author: Grigory Nazarov
View Code
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include <map> 3 #include <queue> 4 #include <vector> 5 #include <string> 6 #include <cmath> 7 #include <cstdio> 8 #include <cstring> 9 #include <cstdlib> 10 #include <iostream> 11 #include <algorithm> 12 using namespace std; 13 #define maxn 5005 14 #define ll long long 15 #define INF 0x7fffffff 16 #define eps 1e-8 17 ll n,m; 18 int main(){ 19 while (~scanf("%I64d", &n)){ 20 ll x = 0, y = 0; 21 x = (n - 3)*n / 2; 22 if (n == 6)y = 6; 23 if (n == 5)x = 0, y = 0; 24 if (n <= 6){printf("%I64d %I64d\n", y, x); continue;} 25 if(n&1)printf("%I64d 0\n", x); 26 else printf("%I64d %I64d\n",x, x); 27 } 28 return 0; 29 }
浙公网安备 33010602011771号