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

  1. 2
  2. 3
  3. 4

Sample Output

  1. YES
  2. NO
  3. YES

Source

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

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. 彻底删除Oracle 11g的方法

    1.关闭oracle所有的服务. 可以在windows的服务管理器中关闭. 2.打开注册表:regedit 打开路径:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlS ...

  2. 小强升职记(GTD)脑图

  3. sphinx设置多属性过滤的方法(setFilter)

    需求描述 mysql中,每一个文档都有多个标签,查询时可以筛选一个标签也可以筛选同时拥有多个标签的文档. 数据示例 文档 标签   1    1,2,3,4,5   2    2,3,4,5,6   ...

  4. Solr3.6.2和Solr4.9.0经常使用配置

    tomcat 以tomcat 7为例,位置/work/apache-tomcat-7.0.55 Solr 3.6.2 基本配置 Solr 3.6.2.须要JDK 6/JDK7支持. 下载Solr 3. ...

  5. CORS解决WebApi跨域问题(转)

    CORS全称Cross-Origin Resource Sharing,中文全称跨域资源共享.它解决跨域问题的原理是通过向http的请求报文和响应报文里面加入相应的标识告诉浏览器它能访问哪些域名的请求 ...

  6. Centos系统安装JDK详细图文教程

    1.查询系统默认JDK Centos系统默认会安装OpenJDK,一般建议是安装sun公司的JDK.我们首先检查系统是否安装有jdk并且是OpenJDK版本的,若是,则将它卸载掉并安装上sun公司的j ...

  7. Mac Yosemite上安装macvim和YouCompleteMe

    今天在macvim上安装YouCompleteMe的时候,碰到一个运行vim崩溃的错误.查了半天终于解决! 先上一下安装macvim的过程 # install xcode and command li ...

  8. Atitit.跨语言异常转换机制 java c# php到js的异常转换

    Atitit.跨语言异常转换机制 java c# php到js的异常转换 1. bizEx   直接抓取,然后js catchEX1 2. Chkec runtimeEx1 3. Other异常..J ...

  9. vivado编译出错 [Synth 8-729] [Synth 8-787]

    http://www.cnblogs.com/pejoicen   打开vivado工程后,发现右上角如下图所示: 重新编译这两个ip核后,对整个工程synthesis,工程报错 [Synth 8-7 ...

  10. vivado笔记

    Vivado主界面 Vivado套件,相当于把ISE.ISim.XPS.PlanAhead.ChipScope和iMPACT等多个独立的套件集合在一个Vivado设计环境中,在这个集合的设计流程下,不 ...