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. Servlet容器 Jetty

    http://www.oschina.net/p/jettyJetty 是一个开源的servlet容器,它为基于Java的web内容,例如JSP和servlet提供运行环境.Jetty是使用Java语 ...

  2. 解决 adb devices :???????????? no permissions 方法

  3. java 重载和多态的区别

    虚拟函数表是在编译期就建立了,各个虚拟函数这时被组织成了一个虚拟函数的入口地址的数组.而对象的隐藏成员--虚拟函数表指针是在运行期--也就是构造函数被调用时进行初始化的,这是实现多态的关键. http ...

  4. Nodejs 命令行交互神奇 yargs

    传送门: # example https://github.com/yargs/yargs/blob/master/docs/examples.md # 官网 http://yargs.js.org/ ...

  5. spring-cloud-config笔记

    忽略元数据末尾 回到原数据开始处 spring-cloud-config 简单来讲就是spring-cloud实现的分布式配置中心.与之前介绍的开源配置服务方案 disconf是一样的,spring- ...

  6. xib autolayout subview

    http://sebastiancelis.com/2014/06/12/using-xibs-layout-custom-views/   initWitchCoder  有点小问题

  7. 新标准C++程序设计读书笔记_继承和多态

    简单继承的例子: #include <iostream> #include <string> using namespace std; class CStudent { pri ...

  8. ext异常,ExceptionReturn

    package cn.edu.hbcf.common.vo; import java.io.PrintWriter; import java.io.StringWriter; /** * Ext 异常 ...

  9. PAT003 List Leaves

    题目: Given a tree, you are supposed to list all the leaves in the order of top down, and left to righ ...

  10. Collection 和 Collections的区别?

    Collection 和 Collections的区别? 解答:Collection是java.util下的接口,它是各种集合的父接口,继承于它的接口主要有Set 和List:Collections是 ...