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. 如何把HTML标记分类

    p.h1.或div等元素常常称为块级元素,这些元素显示为一块内容:Strong,span等元素称为行内元素,它们的内容显示在行中,即“行内框”.(可以使用display=block将行内元素转换成块元 ...

  2. 使用vs远程调试iis站点

    在vs安装目录下IDE文件夹下的Remote Debugger 复制到服务器运行 启动msvsmon.exe msvsmon.exe启动后设置远程连接不验证身份 vs中 调试→附加到进程 ip+端口访 ...

  3. MVC中Area的另一种用法

    [摘要]本文只是为一行代码而分享 context.MapRoute("API", "api/{controller}/{action}", new { }, n ...

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

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

  5. jquery遍历总结(转)

    遍历 DOM jQuery 提供了多种遍历 DOM 的方法. 遍历方法中最大的种类是树遍历(tree-traversal). 下一章会讲解如何在 DOM 树中向上.下以及同级移动. 向上遍历 DOM ...

  6. django源码分析---- Model类型&Field类型

    djiango在数据库这方式自己实现了orm(object relationship mapping 对象关系模型映射).这个主要是用到python 元类这一 项python中的高级技术来实现的. c ...

  7. atitit.jquery tmpl模板总结 .doc

    atitit.jquery tmpl模板总结 .doc 1. atitit.动态模版解析1 1.1. Jquery.tmpl.js1 1.2. 比起anrular js方便啊.1 2. 动态模板引擎解 ...

  8. structs2 获得表单数据

    http://blog.csdn.net/crazy_java1234/article/details/52766307

  9. Scala具体解释---------控制结构和函数

    条件表达式: Scala的if else语法结构和Java的一样.只是,Scala的if else表达式有值.这个值就是跟在if或者else后面的表达式的值. 比如: if(x>0) 0 els ...

  10. 3.2 Zend_Db_Select

    10.4. Zend_Db_Select 你能够使用该对象和它的对应方法构建一个select查询语句,然后生成 字符串符用来传送给zend_db_adapter进行查询或者读取结果. 你也能够在你的查 ...