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 ...
随机推荐
- C#中使用visio控件
C#中使用visio控件 2012-08-25 18:14:19| 分类: 技术相关|举报|字号 订阅 其实就是C#访问VISIO的自动化模型,以前做了不少C#和Excle及word 的交互 ...
- ECshop 二次开发模板教程2
不知道大家是学会用循环了呢,还是我的言语实在有问题,大家实在无法完成阅读哦,居然大家都没有问题,暂时心里安慰,把他当做好事情,大家都会调用了,呵呵,那我们继续循环调用商品了!好,继续在我们昨天的基础上 ...
- Oracle数据库启动时:ORA-00119: invalid specification for system parameter LOCAL_LISTENER; ORA-00132错误解决
问题描述: 1. em打开中提示 https://localhost:1158/em/console/database/instance/repDown?target=orclweng&typ ...
- Android下载速度计算
long startTime = System.currentTimeMillis(); // 开始下载时获取开始时间 long curTime = System.currentTimeMillis( ...
- redis错误汇总
1.redis因为内存不够而启动失败 Microsoft Open Tech group 在 GitHub上开发了一个REDIS Win64的版本,项目地址是:https://github.com/M ...
- 翻译【ElasticSearch Server】第一章:开始使用ElasticSearch集群(3)
运行ElasticSearch(Running ElasticSearch) 让我们运行我们的第一个实例.转到bin目录并从命令行运行以下命令: ./elasticsearch –f (Linux o ...
- CSS定位(CSS定位概述、相对定位、绝对定位、浮动)
CSS 定位属性 CSS 定位属性允许你对元素进行定位. 属性 描述 position 把元素放置到一个静态的.相对的.绝对的.或固定的位置中. top 定义了一个定位元素的上外边距边界与其包含块上边 ...
- 多级联动导航栏(top导航)
http://www.dynamicdrive.com/style/csslibrary/item/jquery_multi_level_css_menu_2/ This is a multi-lev ...
- mapreduce的调度算法和job调优
调度算法: mapreduce当有很多的作业在执行的时候,是按照什么顺序去执行的? 调度算法顺序需要关注: 1.提高作业的吞吐量. 2.要考虑优先级. 三种调度器:如果作业跑不完,并且机器资源利用率比 ...
- js滑动门及对像的使用
function scrollDoor() { } scrollDoor.prototype = { sd: function (menus, divs, openClass, closeClass) ...