Graph(2014辽宁ACM省赛)
生活随笔
收集整理的這篇文章主要介紹了
Graph(2014辽宁ACM省赛)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
問題 F: Graph
時間限制:?1 Sec??內存限制:?128 MB提交:?30??解決:?5
[提交][狀態][論壇]
題目描寫敘述
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坑大爹的一題。該死的費馬數。。。。。
。
p=2^n; 或 p=(2^n)*m; m為若干個不同樣的費馬數的積 //滿足要求的邊為 (2^n)*p p為費馬素數 #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int main() {int n;while(scanf("%d",&n)!=EOF){while(n%2==0){n/=2;}if(n==1){printf("YES\n");continue;}if(n%3==0)n/=3;if(n%5==0)n/=5;if(n%17==0)n/=17;if(n%257==0)n/=257;if(n%65537==0)n/=65537;if(n==1){printf("YES\n");}elseprintf("NO\n");}return 0; }
總結
以上是生活随笔為你收集整理的Graph(2014辽宁ACM省赛)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 第三章:多态
- 下一篇: html-css样式表