CodeForces 592B The Monster and the Squirrel
来源:互联网 发布:利达华信主板数据备份 编辑:程序博客网 时间:2024/05/31 00:40
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 vertex2, 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?
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.
Print the minimum number of jumps Ada should make to collect all the walnuts. Note, that shedoesn't need to leave the polygon after.
5
9
3
1
One of the possible solutions for the first sample is shown on the picture above.
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #define T 54325 using namespace std; typedef long long ll; ll a[T]; void paly_table(){ for(int i=3;i<T;++i){ ll v = i-2; a[i] = v*v; } } int main(){ int n; paly_table(); while(~scanf("%d",&n)){ printf("%I64d\n",a[n]); } return 0; }
- codeforces B. The Monster and the Squirrel
- Codeforces 592B The Monster and the Squirrel 【规律题】
- CodeForces 592B The Monster and the Squirrel
- B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) 592 B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(数学规律)
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2)B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel (规律)
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel
- codeforces round The Monster and the Squirrel 529B (数学规律)
- Codeforces Round #328 (Div. 2)B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(math)
- cf 328div 2 B. The Monster and the Squirrel
- Code Forces 592 B. The Monster and the Squirrel(水~)
- 【Codeforces Round 328 (Div 2)B】【找规律】The Monster and the Squirrel 正多边形连边分割块数
- Codeforces Round #328 (Div. 2)_B. The Monster and the Squirrel
- cf#328-B. The Monster and the Squirrel-水题+数学规律
- iOS-MJRefresh
- 大龄程序员出路在哪里?
- qsort函数用法 (自己加了注释)
- 机器学习基础(三十六)—— 非规整数据(值缺失、异常值)的处理
- 【九度】题目1185:特殊排序
- CodeForces 592B The Monster and the Squirrel
- AppiumDriver driver = new AppiumDriver 的AppiumDriver报错问题解决
- 字符串最后一个单词的长度
- 合并文件的java实现
- 键盘写入文件数据,quit结束
- GreenHandX1h 2016.3.31
- YII 两表间和两模块间的数据库查询
- mysql
- 用星号打印菱形