E: Graph
来源:互联网 发布:宝宝店软件 编辑:程序博客网 时间:2024/04/29 00:05
题目描述
Your task is to judge whether a regular polygon can be drawn only by straightedge and compass.
The length of the straightedge is infinite.
The width of the compass is infinite.
The straightedge does not have scale.
输入
There are several test cases. Each test case contains a positive integer n (3<=n<=10^9). The input will be ended by the End Of File.
输出
If the regular polygon with n sides can be drawn only by straightedge and compass, output YES in one line, otherwise, output NO in one line.
样例输入
34567
样例输出
YESYESYESYESNO看第一眼就知道是数学题,可是自己没有推出公式来啊,o(︶︿︶)o 唉。百度题解才发现,原来是费马数,又学了点新东西。。下面是关于费马数的一点东西,分享一下啦 :http://zh.wikipedia.org/wiki/%E8%B2%BB%E9%A6%AC%E8%B3%AA%E6%95%B8这道题知道下面这个定理就能轻松的A掉了:定理
高斯证明了:可以用尺规(指直尺和圆规)画出正n边形的充要条件是n是2的幂乘以费马素数的积。
AC代码:#include<stdio.h>#include<string.h>int main(){ //freopen("in.txt","r",stdin); int f[5]={3,5,17,257,65537}; int n; while(scanf("%d",&n)!=EOF) { while(n%2==0) { n/=2; } if(n%f[0]==0) n/=f[0]; if(n%f[1]==0) n/=f[1]; if(n%f[2]==0) n/=f[2]; if(n%f[3]==0) n/=f[3]; if(n%f[4]==0) n/=f[4]; if(n==1) printf("YES\n"); else printf("NO\n"); } return 0;}
0 0
- E: Graph
- Codeforces 466 E. Information Graph
- E. Interesting Graph and Apples
- CF 261 E. Pashmak and Graph
- Codeforces 459E Pashmak and Graph
- Codeforces 405 E. Graph Cutting ( DFS )
- Codeforces 405 E. Graph Cutting 【DFS 】
- Graph Cutting CF 405E DFS
- Codeforces 459E Pashmak and Graph【Dp】
- codeforces 459E E. Pashmak and Graph(dp)
- codeforces 459E E. Pashmak and Graph(dp)
- UESTC Training for Graph Theory——E、Distance Queries
- Codeforces 9E Interesting Graph and Apples(并查集)
- Codeforces Round #192 (Div. 2) E. Graph Reconstruction (随机算法)
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph
- Codeforces 459E Pashmak and Graph(dp+贪心)
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph【DP】
- Codeforces Round #261 (Div. 2) E. Pashmak and Graph DP
- OpenCVTurorial1-Cammera Preview
- iOS 各种控件默认高度(图示)
- Rework(重来:更为简单有效的商业思维) --读书笔记
- Linux常用命令小结
- 解析xml串方法C#版&javascript版
- E: Graph
- 使用Data Interoperability扩展模块合并SHP文件
- android 检查网络连接状态实现步骤
- Locations of visitors to this page 常用链接 我的随笔 我的评论 我的参与 最新评论 留言簿(16) 给我留言
- 百度语义理解开放平台使用方法
- Java分布式处理技术(RMI、JNDI)
- 华北黄淮等地“炙烤”天气持续 局地气温可达40℃
- 并查集
- Excel VBA: 按照条件插入行