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. ...
随机推荐
- Java 集合系列 12 TreeMap
java 集合系列目录: Java 集合系列 01 总体框架 Java 集合系列 02 Collection架构 Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例 Java ...
- Windows多线程编程总结
1 内核对象 1 .1 内核对象的概念 内核对象是内核分配的一个内存块,这种内存块是一个数据结构,表示内核对象的各种特征.并且只能由内核来访问.应用程序若需要访问内核对象,需要通过操作系统提供的函数来 ...
- HDU 4036 存疑题目,数论 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=4036 一开始以为需要用斜抛,结果发现只需要用能量守恒定律?+与最大速度的坏土豆速度保持一致 #include & ...
- CodeForces 441E(Codeforces Round #252 (Div. 2))
思路:dp[i][now][mark][len] i 表示当前第i 次now存的是后8位,mark为第9位为0还是1 len第九位往高位还有几位和第9位相等. 只存后8位的原因:操作只有200次 ...
- Windows下为64位的python3.4.3安装numpy
貌似现在没有python3.x的numpy 64位.exe安装包只有.whl的(也可能是我没找到)只能在终端下安装 1.到官网https://www.python.org/downloads/下载py ...
- bzoj 3529 数表 莫比乌斯反演+树状数组
题目大意: 有一张N×m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和j的所有自然数之和.给定a,计算数表中不大于a的数之和. ...
- 企业需要k2来解放孤岛危机
当我谈孤岛危机时,我谈些什么?你以为我要说的是一款风靡的游戏?那恐怕要让你失望了,今天要谈的是“企业管理体系孤岛”,但更多人甚至都没意识到这是危机. 下面的场景,也许你会觉得似曾相识. 场景一 某制鞋 ...
- CSU 1021 B(Contest #3)
Description 从m个不同元素中取出n (n ≤ m)个元素的所有组合的个数,叫做从m个不同元素中取出n个元素的组合数.组合数的计算公式如下: C(m, n) = m!/((m - n)!n! ...
- 经典线程同步 信号量Semaphore
阅读本篇之前推荐阅读以下姊妹篇: <秒杀多线程第四篇一个经典的多线程同步问题> <秒杀多线程第五篇经典线程同步关键段CS> <秒杀多线程第六篇经典线程同步事件Event& ...
- [C/C++]数据类型与变量
1.类型: 1.1.简介 1.1.1.基本类型(base type)和复合类型(compound type): 复合类型是指基于其它类型定义的类型.([1].2.3 p45)那么基本类型就是复合类型基 ...