regular polygon can be drawn only by straightedge and compass

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 

3
4
5
6
7

Sample Output

YES
YES
YES
YES
NO

分析:正 N 边形可用直尺和圆规作出,当且仅当 N  =  2m p1 p2 ...... pk

其中 p1, p2, ......, pk  是互异的费马素数,即形如  的素数。

迄今为止只找到了 F0  = 3F1  = 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;
}




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值