Candy Distribution
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 5868   Accepted: 3274

Description

N children standing in circle who are numbered 1 through N clockwise are waiting their candies. Their teacher distributes the candies by in the following way:

First the teacher gives child No.1 and No.2 a candy each. Then he walks clockwise along the circle, skipping one child (child No.3) and giving the next one (child No.4) a candy. And then he goes on his walk, skipping two children (child No.5 and No.6) and giving the next one (child No.7) a candy. And so on.

Now you have to tell the teacher whether all the children will get at least one candy?

Input

The input consists of several data sets, each containing a positive integer N (2 ≤ N ≤ 1,000,000,000).

Output

For each data set the output should be either "YES" or "NO".

Sample Input

2
3
4

Sample Output

YES
NO
YES

Source

这是一个复杂的数学问题,但是可以通过小数据猜测出来,最后发现只要是2的幂就行,否则不行
#include<cstdio>
using namespace std;
int main()
{
int n;
while(scanf("%d",&n)==)
{
while(n%==)
n/= ;
if(n==)
printf("YES\n");
else
printf("NO\n");
}
return ;
}

poj3372的更多相关文章

  1. poj3372 Candy Distribution

    可以证明: f(k) = k *(k - 1)/ 2 (1 ≤ k ≤ n)是n的完全剩余系当且仅当n = 2 ^ t. http://poj.org/problem?id=3372

随机推荐

  1. loading数据加载的6种形式

    数据加载的几种形式及对应的交互设计 1.全屏加载 多出现在H5页面,例如微信的文章详情页.全屏加载的特点是数据一次性加载完成,内容加载完成之前界面都会停留在loading界面.进度条和有趣的动画设计, ...

  2. 关于wxpy,使用Python玩转微信的问题

    在github上下载了,安装了之后在idle上运行,好像是说Python不能上网.新手求助.现在问题已经解决,是ssl 证书的问题,不能用最新的 复制内容到剪贴板 代码: sudo pip unins ...

  3. Nav titleView 设置的两个方式

    1.self.navigationItem.titleView = vv; 2.[self.navigationController.navigationBar addSubview:vv];

  4. 图片onerror事件,为图片加载指定默认图片

    为图片指定加载失败时显示默认图片,js输出的img对象,onerror是事件,不是属性,所以这样写是不起作用的: var img = $(document.createElement("IM ...

  5. 【转载】 使用rman进行坏块修复(ORA-01578、ORA-01110)

    [转自]http://blog.itpub.net/21256317/viewspace-1062055/ 使用rman进行坏块修复(ORA-01578.ORA-01110) 2012年的一天,处理的 ...

  6. 第一个EJB示例

    FirstEJB2.0.zip Eclipse + JBoss 5.1 Ejb3Example.zip Eclipse + JBoss 7.1 注意点: 1. jboss 增加用户: D:\DevPr ...

  7. Java遍历包中所有类

    PackageUtil 类 import java.io.File; import java.net.URL; import java.net.URLClassLoader; import java. ...

  8. hdoj 1288 Hat's Tea

    Hat's Tea Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total S ...

  9. ajax发送请求时为url添加参数(使用函数)

    <script> // ajax的get请求,使用函数向其url添加参数 function addURLParam(url,name,value){ url+=(url.indexOf(' ...

  10. spring boot +mybatis+druid 多数据源配置

    因为我的工程需要在两个数据库中操作数据,所以要配置两个数据库,我这里没有数据源没有什么主从之分,只是配合多数据源必须要指定一个主数据源,所以我就把 操作相对要对的那个数据库设置为主数据(dataBas ...