poj3372
| 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
#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的更多相关文章
- poj3372 Candy Distribution
可以证明: f(k) = k *(k - 1)/ 2 (1 ≤ k ≤ n)是n的完全剩余系当且仅当n = 2 ^ t. http://poj.org/problem?id=3372
随机推荐
- Task WaitAll的用法
var tasklst = new List<Task>(); ; i < urls.Count; i++) { tasklst.Add(Task.Factory.StartNew& ...
- Linux中history历史命令使用方法详解
当你在玩Linux的时候,如果你经常使用命令行来控制你的Linux系统,那么有效地使用命令历史机制将会使效率获得极大提升.事实上,一旦你掌 握了我在下面给出的15个有关Linux history历史命 ...
- [转载]一种高性能Hierarchical RBAC实现方案
背景 框图 上图中,Role和被设置Permission的Resource都是可以有任意层级继承关系的. 举例 举一个网站的例子来说: 如果,User表示网站用户:Role表示角色:Resource表 ...
- 单元测试时使用Ninject的小问题
主要是Kernel没有被释放,Ninject的Kernel必须调用IDispose释放.也有可能是静态类型在VS单元测试时无法被释放. 先记录下这个问题
- error: Semantic Issue: Interface type cannot be statically allocated
转自:http://hongmin118.iteye.com/blog/1333524 error: Semantic Issue: Interface type cannot be statical ...
- HTTP Basic auth认证
Basic 概述 Basic 认证是HTTP 中非常简单的认证方式,因为简单,所以不是很安全,不过仍然非常常用. 当一个客户端向一个需要认证的HTTP服务器进行数据请求时,如果之前没有认证过,HTTP ...
- xgboost 安装
git clone --recursive https://github.com/dmlc/xgboostcd xgboost/make -j4 cd python-package/ python s ...
- django中使用POST方法 使用ajax后出现“CSRF token missing or incorrect”
这个是因为在django的ajax中默认添加了token,因此需要在cookie中增加token头信息. 首先使用JavaScript函数获取token: function getCookie(nam ...
- Archive for required library xx cannot be read or is not a valid ZIP file
原因:maven下载的jar包有问题,导致maven编译的时候出错 解决方法:找到jar包所在的文件路径,在网上重新下载个相同版本的jar包,问题解决
- 跟着百度学PHP[16]-验证码的学习
一个验证码需要有以下步骤: 验证底图 验证码内容 生成验证码 对比校验 验证码需要依靠PHP的GD扩展库.一些集成环境是默认安装了GD拓展库. <?php //创建一个100*30px图片,默认 ...