Codeforces Round #328 (Div. 2)_B. The Monster and the Squirrel
1 second
256 megabytes
standard input
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?
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 she
doesn'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.
/*题目大意:给n个顶点、从每个顶点发出到其他各顶点的射线,且射线不相交、
* 问这样能将这n边形分成多少个部分 n>=3
*算法分析:给出几组样例: 顶点n 分成部分
3 1
4 4
5 9
6 16
7 25
8 36
不难发现规律 (n-4) * n + 4 (n>=4)
*/ #include <iostream>
#include <cstdio> using namespace std; int main() {
long long int n;
cin >> n;
if (n == 3)
cout << 1<< endl;
else
cout << (n-4) * n + 4<< endl; return 0;
}
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: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...
- 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 #347 (Div.2)_B. Rebus
题目链接:http://codeforces.com/contest/664/problem/B B. Rebus time limit per test 1 second memory limit ...
- Codeforces Round #290 (Div. 2) _B找矩形环的三种写法
http://codeforces.com/contest/510/status/B 题目大意 给一个n*m 找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 ...
随机推荐
- 以深圳.NET俱乐部名义 的技术交流会圆满成功
2017年5月13日的深圳下着暴雨,一场以深圳.NET俱乐部名义的.NET技术交流会在微软Build 2017刚闭幕时在罗湖布吉路与翠山路交界处富基PARK国际6F举办,这次交流以微软Build 20 ...
- [C#]使用Quartz.NET来创建定时工作任务
本文为原创文章.源代码为原创代码,如转载/复制,请在网页/代码处明显位置标明原文名称.作者及网址,谢谢! 开发工具:VS2017 语言:C# DotNet版本:.Net FrameWork 4.0及以 ...
- Nginx (二) Nginx的反向代理负载均衡以及日志切割
Nginx是一个高并发,高性能的服务器,可以进行反向代理以及网站的负载均衡.这些功能的运用都在配置文件中,也就是Nginx安装目录下的conf/nginx.conf. nginx.conf 1. 先来 ...
- Raspberry Pi中可用的Go IDE:liteide
p { margin-bottom: 0.25cm; line-height: 120% } a:link { } Raspberry Pi中可用的Go IDE:liteide p { margin- ...
- F和弦大横按
用食指手掌关节顶住. 靠近品柱往上压 右手压住琴尾,这样就很轻松试下C跟F不停转换就快找到感觉 等熟练了,食指自然不会按太上 练得差不多了,手指向琴头倾压,有两个好处 1.手指后面的肉不会碰到弦 2. ...
- springBoot系列教程08:拦截器(Interceptor)的使用
拦截器intercprot 和 过滤器 Filter 其实作用类似 在最开始接触java 使用struts2的时候,里面都是filter 后来springmvc时就用interceptor 没太在意 ...
- 对vuex的认识和简单理解
vuex概述 Vuex 是一个主要应用在中大型单页应用的类似于 Flux 的数据管理架构.它主要帮我们更好地组织代码,以及把应用内的的状态保持在可维护.可理解的状态. 但如果是简单的应用 ,就没有必要 ...
- 公众号的Markdown排版利器:Md2All
微信公众号:颜家大少如有问题或建议,请公众号留言 本文所用排版工具:Md2All,http://md.aclickall.com 公众号排版工具 公众号的排版编辑工具还真的不少,但功能大同小异,大部分 ...
- 七行代码开始flask
前言: 对于现有的企业接口服务实现方式来说,Java比较适用于大型的并发式的业务场景:而对一些低IO的且功能简单的数据接口来说,Python似乎更合适.近几年流行的Flask可以说是专为接口式开发而生 ...
- js 判断值为Array or Object的方法
①obj instanceof Array / Object ②Array.prototype.isPrototypeOf(obj) ③Object.prototype.toString.call(o ...