regular polygon can be drawn only by straightedge and compass
来源:互联网 发布:网络it需要什么学历 编辑:程序博客网 时间:2024/04/23 21:15
Description
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.
Input
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.
Output
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.
Sample Input
34567
Sample Output
YESYESYESYESNO
分析:正 N 边形可用直尺和圆规作出,当且仅当 N = 2m p1 p2 ...... pk
其中 p1, p2, ......, pk 是互异的费马素数,即形如 的素数。
迄今为止只找到了 F0 = 3, F1 = 5, F2 = 17, F3 = 257, F4 = 65537 这五个费马素数
#include <cstdio>const int fima[] = {3, 5, 17, 257, 65537};int main(){int x;while(~scanf("%d", &x)) {int yes = 0;for(int i=0; i<5; i++) if(x%fima[i]==0) x/=fima[i]; for(int i=0; i<30; i++) if((x==(1<<i))) { yes = 1; break; } printf("%s\n", yes?"YES":"NO");} return 0;}
1 0
- regular polygon can be drawn only by straightedge and compass
- Solaris11 :Roles can only be assumed by authorized users
- Regular Expression Matching Can Be Simple And Fast
- Regular Expression Matching Can Be Simple And Fast
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Limit the textbox only can be inputed with number and paste no more than 9 chars
- java.lang.UnsatisfiedLinkError: 动态库 : 动态库:only ET_DYN and ET_EXEC can be loaded
- C++编译错误"a storage class can only be specified for objects and functions"解决
- <merge /> can be used only with a valid ViewGroup root and attachToRoot=true
- C++编译错误"a storage class can only be specified for objects and functions"解决方法
- CommandError: App 'article' has migrations. Only the sqlmigrate and sqlflush commands can be used wh
- a label can only be part of a statement and a declaration is not a statement
- 前端持续关注(1)-JSP和前端不明白的地方[渲染,json]
- A very hard Aoshu problem
- php.ini文件 open_basedir参数
- Android Service之串行化Service:IntentService(系列3)
- C++ 中的 Lambda 表达式
- regular polygon can be drawn only by straightedge and compass
- Xcode或模拟器运行时错误总结
- MapReduce架构
- 面试题16:反转链表
- 大扫除与代码重构
- PHP 函数ignore_user_abort ()
- ios学习之uisplitview的自定义代理的学习
- Struts2上传文件
- android WebView总结