Codeforces 592B The Monster and the Squirrel 【规律题】

来源:互联网 发布:三星s8打不开淘宝 编辑:程序博客网 时间:2024/05/30 19:32

B. The Monster and the Squirrel
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Ari the monster always wakes up very early with the first ray of the sun and the first thing she does is feeding her squirrel.

Ari draws a regular convex polygon on the floor and numbers it's vertices 1, 2, ..., n in clockwise order. Then starting from the vertex 1she draws a ray in the direction of each other vertex. The ray stops when it reaches a vertex or intersects with another ray drawn before. Ari repeats this process for vertex 2, 3, ..., n (in this particular order). And then she puts a walnut in each region inside the polygon.

Ada the squirrel wants to collect all the walnuts, but she is not allowed to step on the lines drawn by Ari. That means Ada have to perform a small jump if she wants to go from one region to another. Ada can jump from one region P to another region Q if and only if P and Qshare a side or a corner.

Assuming that Ada starts from outside of the picture, what is the minimum number of jumps she has to perform in order to collect all the walnuts?

Input

The first and only line of the input contains a single integer n (3 ≤ n ≤ 54321) - the number of vertices of the regular polygon drawn by Ari.

Output

Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that she doesn't need to leave the polygon after.

Sample test(s)
input
5
output
9
input
3
output
1
Note

One of the possible solutions for the first sample is shown on the picture above.




题意:给定一个正n多边形,从它的顶点1引出一条射线,当碰到边、顶点反弹光线,问最后可以把多边形分成多少个区域。


规律 ->  (n-2) * (n-2)



#include <cstdio>#include <cstring>#include <algorithm>#include <queue>#include <stack>#include <map>#define LL long long#define INF 0x3f3f3f3f#define debug printf("1\n")using namespace std;int main(){    LL n;    while(scanf("%lld", &n) != EOF)    {        printf("%lld\n", (n-2)*(n-2));    }    return 0;}





1 0