Code Forces 592 B. The Monster and the Squirrel(水~)
来源:互联网 发布:淘宝清洗订单会降权吗 编辑:程序博客网 时间:2024/05/20 09:20
Description
给出一个正n边形,现从顶点1开始向每个非相邻顶点连边,每条边遇到其他边就停止(n=5时如下图),问最后这些边把整个多边形分成几块
Input
一个整数n表示多边形边数(3<=n<=54321)
Output
输出连的边将多边形分成几部分
Sample Input
5
Sample Output
9
Solution
第一个点连完边后多边形变成n-2块,对这n-2块中任意一块,设三个端点为1,a,b,那么a会向b右侧除1和b之外的点连边,b会向a左侧除1和a之外的点连边(这里的边只考虑在这一块中的边),那么这一块就被分成了n-2块,所以一共(n-2)^2块
Code
#include<stdio.h>typedef long long ll;int main(){ ll n; while(~scanf("%I64d",&n)) printf("%I64d\n",(n-2)*(n-2)); return 0;}
0 0
- Code Forces 592 B. The Monster and the Squirrel(水~)
- codeforces B. The Monster and the Squirrel
- B. The Monster and the Squirrel
- Codeforces 592B The Monster and the Squirrel 【规律题】
- CodeForces 592B The Monster and the Squirrel
- cf 328div 2 B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) 592 B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(数学规律)
- codeforces round The Monster and the Squirrel 529B (数学规律)
- The Monster and the Squirrel(规律题)
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel
- cf#328-B. The Monster and the Squirrel-水题+数学规律
- Codeforces Round #328 (Div. 2)B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel (规律)
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2)B. The Monster and the Squirrel
- Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel(math)
- Code Forces 558 B. Amr and The Large Array(水~)
- 项目忽然出现 The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path 解决方法
- windows下,在python中安装xgboost的简易方法,解决 error C3861: “sleep”: 找不到标识符”
- JavaScript学习笔记1
- python--字典排序
- 走向心灵的轻音乐
- Code Forces 592 B. The Monster and the Squirrel(水~)
- 黑马程序员-Java中基本类型对应的类(装箱与拆箱)
- 爬爬爬之路:UI(十五) KVO
- bzoj2823[AHOI2012]信号塔
- Installation error:INSTALL_FAILED_VERSION_DOWNGRADE
- JavaWeb 利用springsecurity做用户权限限制
- IOS消息推送之APNS
- 使用OPENCV训练手写数字识别分类器
- 应用JavaScript脚本验证表单元素是否为空