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. jenkins构建执行shell 所有命令出现command not found

    出现的问题: + rsync -avzP /mnt/workspace/df-admin/ root@192.168.0.153:/home/deploy/deep_fashion_targets/w ...

  2. Ubuntu13.04使用Jlink和ST-Link V2烧写STM32F1x和STM32F4x

    近期做研究openpilot和crazyflie2.0,都须要在Linux进行代码的编写和烧录,所以研究了下Linux下如何使用Jlink,还有开源的支持多个仿真器的openocd,可是困难重重.总是 ...

  3. sublime for mac 注册码

    https://www.jianshu.com/p/04e1b65dd2c0https://fatesinger.com/100121

  4. 一.软件介绍(apache lighttpd nginx)

    一.软件介绍(apache  lighttpd  nginx) 1. lighttpd Lighttpd是一个具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点.lighttpd是众多 ...

  5. Objective-C中的类型转换

    转自:http://blog.csdn.net/lonelyroamer/article/details/7711920 类型转换 表2-3列出了简单数据类型.示例和格式符. 表2-3 简单数据类型. ...

  6. BZOJ 3000(Big Number-Stirling公式求n!近似值)

    3000: Big Number Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 220  Solved: 62 [Submit][Status] De ...

  7. 公共查询类criteria

    package cn.edu.hbcf.common.vo; import java.math.BigDecimal; import java.sql.Timestamp; import java.u ...

  8. 搭建hadoop集群,

    这个教程是2.4.1的 ,但是亲测对于2.6.5,是可以用的,对2.5.4应该也是支持的 1.准备Linux环境 1.0先将虚拟机的网络模式选为NAT 1.1修改主机名 vi /etc/sysconf ...

  9. JavaScript绘图类 (DIV绘图)

    主要的图形算法抄自一个叫w_jsGraphics.js的类库,第一次看到那个库的时候,感觉那是十分神奇的存在.不过估计现在那个库早就已经找不到了. 这是很早之前的一个DIV绘图类,那时候VML+SVG ...

  10. Linux制作wifi热点/无线路由

    参考: http://blog.csdn.net/u011641885/article/details/495121991.工具/原料    有无线网卡(usb接口的RT3070无线网卡).有线网卡的 ...