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
随机推荐
- ps修图之——四步去修图后的毛边
PS修图时,多数PS工具都会在图片的边源处留下很多毛边如下图: 这个时候很多新手店主会非常苦脑,会退回原始图片上反复修图起图.可是结果也不怎么满意,当然也许有些店主会有其它方法. 其实不用那么麻烦,只 ...
- T-sql isnull函数介绍
今天在给同事调取数据的时候,同事反馈说数据偏少,我仔细检查,发现sql语句条件都正确,逻辑没哪里不对,最后经过仔细排查,才发现问题出在null字段上 表中有一列是允许为null值,比如查询名字不为测试 ...
- 转载 :sql server分区 http://blog.itpub.net/27099995/viewspace-1081158/
转载:http://blog.itpub.net/27099995/viewspace-1081158/ 在 sql server 2005 之前不提供分区表,但可以用其他方式建立“分区表”,sql ...
- [Oracle] enq: TX - row lock contention 优化案例
依据开发反馈.近期每天早上7:30应用会报警.应用的日志显示数据库连接池满了.新的连接被拒绝. 首先.我做了ASH报告(报告区间:7:25 ~ 7:35),从ASH的等待事件发现enq: TX - r ...
- centos终端显示-bash-4.2#解决方法
登录linux系统过后,发现显示的是-bash-4.2# 而不是root@主机名 + 路径的显示方式,发生这种情况的原因是根目录下缺失几个配置文件,从默认配置中拷贝过来就可以解决了: cp /etc/ ...
- Python基础--字典:当索引不好用时
当列表或是元组的索引不能达到我们的目的时,我们想到了还有一种序列,即字典. 创建 字典 由多个键以及相应的值构成的键-值对组成. 键唯一.值能够不唯一 phonebook = {'xidada':'1 ...
- 远程重启WIN服务器
- mysql启动与关闭
撰于:http://wenku.baidu.com/link?url=QV3mEJWnU4c8VZPjKGxz4A8gSmdjO2HZY7n963UaVx4l_uPKrh16tGxLyqjf5i3MA ...
- 编程算法 - 高速排序算法 代码(C)
高速排序算法 代码(C) 本文地址: http://blog.csdn.net/caroline_wendy 经典的高速排序算法, 作为一个编程者, 不论什么时候都要完整的手写. 代码: /* * m ...
- Jmeter常用操作
一,Jmeter-http 接口脚本添加cookie 实例:学生金币充值接口 该接口有权限验证,需要admin 用户才可以操作,需要添加cookie cookie 中key 为登录的用户名,valu ...