Codeforces Round #328 (Div. 2) B
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-1个点划线 不能与已经划的线相交 问分成了多少 部分
题解:找规律
n 3 4 5 6 ....
ans 1 4 9 16....
3 5 7 插值 为2的等差
#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#define ll __int64
#define pi acos(-1.0)
using namespace std;
ll n;
ll ans;
ll exm;
int main()
{ ans=;
exm=;
scanf("%I64d",&n);
for(ll i=;i<=n;i++)
{
ans+=exm;
exm+=;
}
cout<<ans<<endl;
return ;
}
Codeforces Round #328 (Div. 2) B的更多相关文章
- Codeforces Round #328 (Div. 2) D. Super M
题目链接: http://codeforces.com/contest/592/problem/D 题意: 给你一颗树,树上有一些必须访问的节点,你可以任选一个起点,依次访问所有的必须访问的节点,使总 ...
- 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) 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) 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) A. PawnChess 暴力
A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...
- Codeforces Round #328 (Div. 2)
这场CF,准备充足,回寝室洗了澡,睡了一觉,可结果... 水 A - PawnChess 第一次忘记判断相等时A先走算A赢,hack掉.后来才知道自己的代码写错了(摔 for (int i=1; ...
- 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)_A. PawnChess
A. PawnChess time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #328 (Div. 2) A
A. PawnChess time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codeforces Round #328 (Div. 2) C 数学
C. The Big Race time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...
随机推荐
- LeetCode969. 煎饼排序
问题:969. 煎饼排序 给定数组 A,我们可以对其进行煎饼翻转:我们选择一些正整数 k <= A.length,然后反转 A 的前 k 个元素的顺序.我们要执行零次或多次煎饼翻转(按顺序一次接 ...
- filebeat的安装及配置
概述:Filebeat是一个日志文件托运工具,在你的服务器上安装客户端后,filebeat会监控日志目录或者指定的日志文件,追踪读取这些文件(追踪文件的变化,不停的读),并且转发这些信息到elasti ...
- Mysql_Binary_Install_Scripts(采用二进制方式安装)
1.1 MYSQL实现代码 #!/bin/bash ######################################## #auth:wolf_dreams #time:2018-1 ...
- anaconda+jupyter notebook 安装配置
安装Anaconda 从清华大学开源软件镜像站选择合适自己的版本 wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda ...
- PHP表单安全过滤和防注入 htmlspecialchars() 和test_input()
什么是 htmlspecialchars() 函数? htmlspecialchars() 函数把特殊字符转换为 HTML 实体.这意味着 < 和 > 之类的 HTML 字符会被替换为 & ...
- python 学习心得
多用类或是函数 我以前写的时候,不用函数,从头写到尾,后来,要改成函数,也是要花很多测试的时间,改的话还得一个调试,如果一开始就用函数的话,就能节省很多时间. 函数的功能尽可能的小 比如说像我用try ...
- emplace_back
c++11 的 list deque 和 vector 增加了emplace_back函数,相对于push_back函数,它减少了一次类的构造,因此效率更高,推荐使用. #include <li ...
- linux处理僵尸进程
由来 在linux下,如果一个进程终止,内核会释放该进程使用的所有存储区,关闭所有文件句柄等,但是,内核会为每个终止子进程保留一定量的信息.这些信息至少包括进程ID,进程的终止状态,以及该进程使用的C ...
- C语言进阶—— 接续符和转义符13
接续符的意义: C语言中的接续符 (\) 是指示编译器行为的利器 我们来看一个案例: #in\ clud\ e <st\ dio.h> in\ t m\ ain(\ ) { pri\ nt ...
- 基本形状的绘制&添加文字
本次用opencv在图像上绘制了线,矩形,椭圆,圆的形状和放置了文字. #include<iostream> using namespace std; using namespace cv ...