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

Codeforces Round #328 (Div. 2) B

时间:2016-07-20 22:55:03      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

Description

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 1 she 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 Q share 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 shedoesn‘t need to leave the polygon after.

Examples
input
5
output
9
input
3
output
1
Note

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

 找规律,就是正多边形,顶点相连,已经相连的后面的就会截断,问能划分多少区域

#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    cout<<(n-2)*(n-2)<<endl;
    return 0;
}

  

Codeforces Round #328 (Div. 2) B

标签:

原文地址:http://www.cnblogs.com/yinghualuowu/p/5689847.html

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