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.
//滿足要求的邊為 (2^n)*p p為費馬素數 #include#include #include #include #include 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"); } else printf("NO\n"); } return 0; }