Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel
2015-11-03 23:50
513 查看
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 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 test(s)
input
output
input
output
Note
One of the possible solutions for the first sample is shown on the picture above.
解题报告: Codeforces Round #328 Problem Analysis
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 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 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.
解题报告: Codeforces Round #328 Problem Analysis
相关文章推荐
- poj3368 Frequent values
- IOS UIButton
- Reveal-Plugin-for-Xcode 自动结合 Reveal 进行 UI 分析
- programming-challenges The Tourist Guide (110903) 题解
- UGUI事件解析
- 【UI基础】抽屉效果简单实现
- 线性结构3 Pop Sequence(PAT)
- 线性结构3 Pop Sequence(PAT)
- POJ 2524 Ubiquitous Religions
- IOS UILabel
- IOS基础UI之(九) UIPageControl结合UIScrollView实现分页效果
- String 、StringBuffer 、StringBuilder区别是什么?
- [LeetCode] Longest Increasing Subsequence
- IOS自学之UIview属性
- iOS—UI —推送实现
- 解决confluence的乱码问题
- UIImageView不能设置圆角的解决方法
- 【LEETCODE】96-Unique Binary Search Trees
- hdu1159 Common Subsequence(LCS)
- 【Android】安卓UI 进度对话框ProgressDialog