Candy Distribution
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6033   Accepted: 3351

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 老师给糖给 1 2号学生,然后接下来隔着一个学生给糖,隔着两个学生给糖,问一直这样下去,是否所有学生都会拿到糖? 找规律,判断 n是否为 2^k...快速判断 n是否为 2的指数幂的方法 n&n-1...
#include <stdio.h>
#include <algorithm>
#include <string.h>
using namespace std;
typedef long long LL;
const int N = ; int main()
{
int n;
while(scanf("%d",&n)!=EOF){
if((n&(n-))==) printf("YES\n");
else printf("NO\n");
}
return ;
}

poj 3372(找规律)的更多相关文章

  1. POJ 1740 A New Stone Game 又是博弈论配对找规律orz 博弈论 规律

    http://poj.org/problem?id=1740 这个博弈一眼看上去很厉害很高大上让人情不自禁觉得自己不会写,结果又是找规律…… 博弈一般后手胜都比较麻烦,但是主要就是找和先手的对应关系, ...

  2. 【poj 3090】Visible Lattice Points(数论--欧拉函数 找规律求前缀和)

    题意:问从(0,0)到(x,y)(0≤x, y≤N)的线段没有与其他整数点相交的点数. 解法:只有 gcd(x,y)=1 时才满足条件,问 N 以前所有的合法点的和,就发现和上一题-- [poj 24 ...

  3. 【poj 2478】Farey Sequence(数论--欧拉函数 找规律求前缀和)

    题意:定义 Fn 序列表示一串 <1 的分数,分数为最简分数,且分母 ≤n .问该序列的个数.(2≤N≤10^6) 解法:先暴力找规律(代码见屏蔽处),发现 Fn 序列的个数就是 Φ(1)~Φ( ...

  4. poj 2440 (找递推公式)

    http://poj.org/problem?id=2440 DNA Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3254 ...

  5. 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用

    转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...

  6. POJ2992:Divisors(求N!因子的个数,乘性函数,分解n!的质因子(算是找规律))

    题目链接:http://poj.org/problem?id=2992 题目要求:Your task in this problem is to determine the number of div ...

  7. POJ2505 A multiplication game 博弈论 找规律

    http://poj.org/problem?id=2505 感觉博弈论只有找规律的印象已经在我心中埋下了种子... 题目大意:两个人轮流玩游戏,Stan先手,数字 p从1开始,Stan乘以一个2-9 ...

  8. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

  9. HDU 5703 Desert 水题 找规律

    已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...

随机推荐

  1. Python完成RF测试用例

    Robot Framework 框架是基于 Python 语言开发的,所以,它本质上是 Python 的一个库. from robot.api import TestSuite from robot. ...

  2. NAT ------ 内网的主机如何通过路由器与外网的主机通信

    内网主机A,路由器B,外网主机C 使用了两个协议: 路由:位于网络层,为数据包提供一个寻径的算法,不改变数据包的源IP和目的IP,但是会修改源MAC和目的MAC,只在同个网段的进行数据的转发 NAT: ...

  3. 【Asp.net入门5-04】SportsStore之添加分页

  4. PyQt 5.4参考指南 ---- PyQt5和PyQt4之间的差异

    欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章 sklearn实战-乳腺癌细胞数据挖掘(博主亲自录制视频) https://study.163.com/course/in ...

  5. css table 合并单元格

    1. css table 合并单元格 colspan:合并列, rowspan:合并行, 合并行的时候,比如rowspan="2",它的下一行tr会少一列: 合并列的时候,比如co ...

  6. 搞ACM的你伤不起[转载] 原作者:RoBa

    劳资六年前开始搞ACM啊!!!!!!!!!! 从此踏上了尼玛不归路啊!!!!!!!!!!!! 谁特么跟劳资讲算法是程序设计的核心啊!!!!!! 尼玛除了面试题就没见过用算法的地方啊!!!!!! 谁再跟 ...

  7. weblogic 反序列化补丁绕过漏洞的一个批量检测shell脚本(CVE-2017-3248 )

    ~ 以下内容,仅供学习参考 ~ weblogic 反序列化补丁绕过漏洞已经出了两个月了,balabala ~~~ 废话不说,拿到该漏洞的利用工具weblogic.jar,但只能一个个检测ip和端口,效 ...

  8. post请求远程url 报错“基础连接已经关闭...Authentication.AuthenticationException...远程证书无效”解决方案

    当我们有时用代码编写post请求url远程地址会报“基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系. ---> System.Security.Authentication.A ...

  9. beego项目运行过程

    一:首先man.go,整个程序的入口 func main() { beego.Run() } 然后beego.run()代码 // Run beego application. // beego.Ru ...

  10. popular short sentences

    backward compatibility 向后兼容 archive 文档