Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel 打表数学
B. The Monster and the Squirrel
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/592/problem/B
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
Sample Output
9
HINT
题意
每个点依次和其他点连线,如果这条直线连接的过程中,和另外一条直线相交的话,就会被截断
然后问你,正n边形,被截成了多少块
题解:
打表吧,在纸上画画,然后就找到规律了……(n-2)*(n-2)
详细证明:
After drawing the rays from the first vertex (n - 2) triangles are formed. The subsequent rays will generate independently sub-regions in these triangles. Let's analyse the triangle determined by vertices 1, i, i + 1, after drawing the rays from vertex i and (i + 1) the triangle will be divided into (n - i) + (i - 2) = n - 2 regions. Therefore the total number of convex regions is (n - 2)2
If the squirrel starts from the region that have 1 as a vertex, then she can go through each region of triangle (1, i, i + 1) once. That implies that the squirrel can collect all the walnuts in (n - 2)2 jumps.
代码
#include<iostream>
using namespace std; int main()
{
long long n;
cin>>n;
cout<<(n-2LL)*(n-2LL)<<endl; }
Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel 打表数学的更多相关文章
- Codeforces Round #328 (Div. 2)_B. The Monster and the Squirrel
B. The Monster and the Squirrel time limit per test 1 second memory limit per test 256 megabytes inp ...
- Codeforces Round #328 (Div. 2)
这场CF,准备充足,回寝室洗了澡,睡了一觉,可结果... 水 A - PawnChess 第一次忘记判断相等时A先走算A赢,hack掉.后来才知道自己的代码写错了(摔 for (int i=1; ...
- Codeforces Round #328 (Div. 2) B
B. The Monster and the Squirrel time limit per test 1 second memory limit per test 256 megabytes inp ...
- Codeforces Round #328 (Div. 2) D. Super M 虚树直径
D. Super M Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/D ...
- Codeforces Round #328 (Div. 2) D. Super M
题目链接: http://codeforces.com/contest/592/problem/D 题意: 给你一颗树,树上有一些必须访问的节点,你可以任选一个起点,依次访问所有的必须访问的节点,使总 ...
- Codeforces Round #328 (Div. 2) C. The Big Race 数学.lcm
C. The Big Race Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/probl ...
- Codeforces Round #328 (Div. 2) A. PawnChess 暴力
A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...
- Codeforces Round #459 (Div. 2)C. The Monster
C. The Monster time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #328 (Div. 2)_A. PawnChess
A. PawnChess time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- codeforces 679A Bear and Prime 100 交互
第一次交互题,记录一下吧 #include <cstdio> #include <iostream> #include <ctime> #include <v ...
- cadence异型孔
1:画route path的边框,画在board geometry的ncroute_path层上,可以用zcopy (暂时没用过) 没有的话可能:WARNING: No route path ...
- c#基类 常用数据验证的封装,数字,字符,邮箱的验证
#region 常用数据验证的封装,数字字符的验证 /// <summary> /// 常用数据验证的封装,数字字符的验证 /// </summa ...
- asp.net 常用的几种调用存储过程的方法
(1)简单的无参数存储过程 create procedure ExpOneasselect top 10 * from Corpgo C#调用此存储过程 SqlConnection co ...
- php 解决微信昵称emoji表情插入MySQL报错
在PHP接受到微信用户昵称入库的时候报错 原因:utf-8 最大3个字节,而emoji占4个字节 解决办法: 1.修改mysql 数据库的字符集,改为utf8mb4,但是前提是MySQL的版本需要5. ...
- andriod的简单用法2
1.在Activity中使用menu //创建菜单项 public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this ...
- [Hive - LanguageManual] Import/Export
LanguageManual ImportExport Skip to end of metadata Added by Carl Steinbach, last edited by Le ...
- linux下无法安装VMware的解决方法
在Reahat下安装VMware-Player-6.0.1-1379776.x86_64.bundle,结果却提示 Extracting VMware Installer...done.NOT_REA ...
- 快速建立Linux c/c++编译环境
sudo apt-get install build-essential 省时又省心~
- 从使用到原理学习Java线程池
线程池的技术背景 在面向对象编程中,创建和销毁对象是很费时间的,因为创建一个对象要获取内存资源或者其它更多资源.在Java中更是如此,虚拟机将试图跟踪每一个对象,以便能够在对象销毁后进行垃圾回收. 所 ...