codeforces round The Monster and the Squirrel 529B (数学规律)
来源:互联网 发布:51单片机串口 编辑:程序博客网 时间:2024/05/20 05:57
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 she doesn't need to leave the polygon after.
Sample Input
5
9
3
1
Hint
One of the possible solutions for the first sample is shown on the picture above.
//题意可转化为给你一个凸多边形,每个点有标号为1,2,3,........n。从1向不与它相邻的点连线,然后依次是2,3,....n,但后边的不能穿过前面的线。问这么多的线把这个凸多边形分为几部分。
枚举前几个发现规律
#include<stdio.h>#include<string.h>int main(){__int64 n,m;while(scanf("%I64d",&n)!=EOF){printf("%I64d\n",(n-2)*(n-2));}return 0;}
- codeforces round The Monster and the Squirrel 529B (数学规律)
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(数学规律)
- Codeforces 592B The Monster and the Squirrel 【规律题】
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel (规律)
- codeforces 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-水题+数学规律
- 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(math)
- Codeforces Round #328 (Div. 2) 592 B. The Monster and the Squirrel
- CodeForces 592B The Monster and the Squirrel
- The Monster and the Squirrel(规律题)
- B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2)_B. The Monster and the Squirrel
- cf 328div 2 B. The Monster and the Squirrel
- Mybatis与Ibatis比较
- Swift(十、类和结构体)
- hdu5146
- iOS中关于绘图板的小demo
- 2015 11 01 结构体指针
- codeforces round The Monster and the Squirrel 529B (数学规律)
- [课堂实践与项目]IOS网络下载之 Post请求和Get请求
- 为什么上传文件的表单需要设置enctype="multipart/form-data"
- leetcode之House Robber(打家劫舍)
- C数据结构学习历程(3) 顺序栈之 一般表达式转化后缀式
- Linux下实现一个带时标的消息打印
- jdk升级
- synchronized详解
- poj 1011