Candy Distribution_找规律
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6012 | Accepted: 3341 |
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
【思路】找规律,是2的指数输出yes否则no
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
long long n;
while(~scanf("%lld",&n))
{
while(n)
{
if(n&) break;//二进制数最右位为1时,若n为1,则为2的指数,否则不能除2了也要退出
n>>=;//相当于每次除2 }
if(n==) printf("YES\n");
else printf("NO\n");
}
return ;
}
Candy Distribution_找规律的更多相关文章
- HDU 5795 A Simple Nim (博弈 打表找规律)
A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...
- poj 3372(找规律)
Candy Distribution Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6033 Accepted: 335 ...
- hdu 3951 - Coin Game(找规律)
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...
- HDU 5703 Desert 水题 找规律
已知有n个单位的水,问有几种方式把这些水喝完,每天至少喝1个单位的水,而且每天喝的水的单位为整数.看上去挺复杂要跑循环,但其实上,列举几种情况之后就会发现是找规律的题了= =都是2的n-1次方,而且这 ...
- hdu4952 Number Transformation (找规律)
2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...
- CF456B Fedya and Maths 找规律
http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...
- hdu 4731 2013成都赛区网络赛 找规律
题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举
- 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake
题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...
- 找规律 ZOJ3498 Javabeans
Javabeans are delicious. Javaman likes to eat javabeans very much. Javaman has n boxes of javabeans. ...
随机推荐
- 《精通javascript》几个简单的函数
转载http://www.cnblogs.com/jikey/archive/2011/07/25/2116696.html /** * 隐藏元素 * @param {String} elem */f ...
- 简单springMVC环境搭建
web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="htt ...
- lucene Lock obtain timed out: Lock@
出错界面: 解决办法: 出现以上异常主要有两种原因: 1.系统正在写索引未完成之前,应用程序关闭 解决方法:删除提示的lock文件后重启应用(最好在应用中捕捉到,自动删除) 2.系统中有多个线程或程序 ...
- JGibbLDA、GibbsLDA++问题解决
LDA(Latent Dirichlet Allocation )主题模型是一种用统计进行文本挖掘的方法,它是pLSA(概率潜在语义分析)主题模型基础上加上贝叶斯框架而得到的模型.目前已应用于自然语言 ...
- MVC扩展ValueProvider,通过实现IValueProvider接口创建SessionValueProvider
□ ValueProvider的大致工作原理 →通过Request.Form, Request.QueryString, Request.Files, RouteData.Values获取数据.→然后 ...
- 【转载】如何在德州仪器网站查找和下载PCB封装
德州仪器的网站做得相当不错,查找IC资料和下载IC封装样样给力.那么如何在TI网站上能够快速查找到自已需要的PCB封装呢?下面我来告诉你. 1. 在浏览器中输入网址http://weben ...
- 转载 jQuery validation
之前做客户端验证感觉自己javascript 不行,虽然能写出来一完整的验证,但从不自信,一直觉得客户端验证是比较繁琐的事情,但是又不能不做,只到最开始接触ajax ,遇到了一个jQuery vali ...
- Octopus系列之SQLite3常用命令
导出脚本F:\B2CShop>sqlite3 B2CDB.db .dump > test.sql 导入脚本F:\B2CShop>sqlite3 B2CDB.db < B2C-S ...
- Jquery select 选中项中自定义的值
给select 赋值,除了已有的value及text,新建一属性simple_name function GetDicOfficeList(dicType, sid) { $.ajax({ url: ...
- Swift - 自动布局库SnapKit的使用详解3(约束优先级,约束做动画)
1,约束优先级我们使用SnapKit的时候,还可以定义约束的优先级.这样当约束出现冲突的时候,优先级高的约束覆盖优先级低的约束.具体优先级可以放在约束链的结束处. (1)可以设置如下几种优先级 pri ...