题目描述
过年了,N个学生站成一圈,按顺时针方向依次编号为1到N,等待他们的糖果。老师按照以下方法来分配糖果:
首先老师给1号和2号学生各一块糖果,然后他沿着圆圈按照顺时针方向继续分发,跳过一个学生(3号),给下一个学生(4号)一块糖果;继续行走,跳过2个学生(5号和6号)给下一个学生(7号)一块糖果,如此反复进行。
问能否保证每个学生都能至少得到一块糖果?
输入
输入有多组测试数据,每个测试数据是一个正整数N(2<=N<=1000000000)
输出
对于每组测试数据输出:“YES”或者“NO”
Code
#include<bits/stdc++.h>
using namespace std;
int n;
int tot;
int main()
{
freopen("candy.in","r",stdin);
freopen("candy.out","w",stdout);
while (scanf("%d",&n) != EOF)
{
tot = 1;
for (int i = 1;i <= n;i++)
{
tot = tot * 2;
if (tot > n)
{
printf("NO\n");
break;
}
if (tot == n)
{
printf("YES\n");
break;
}
}
}
return 0;
}