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_找规律的更多相关文章

  1. HDU 5795 A Simple Nim (博弈 打表找规律)

    A Simple Nim 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5795 Description Two players take turns ...

  2. poj 3372(找规律)

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

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

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

  4. HDU 5703 Desert 水题 找规律

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

  5. hdu4952 Number Transformation (找规律)

    2014多校 第八题 1008 2014 Multi-University Training Contest 8 4952 Number Transformation Number Transform ...

  6. CF456B Fedya and Maths 找规律

    http://codeforces.com/contest/456/problem/B CF#260 div2 B Fedya and Maths Codeforces Round #260 B. F ...

  7. hdu 4731 2013成都赛区网络赛 找规律

    题意:找字串中最长回文串的最小值的串 m=2的时候暴力打表找规律,打表可以用二进制枚举

  8. 找规律 Codeforces Round #290 (Div. 2) A. Fox And Snake

    题目传送门 /* 水题 找规律输出 */ #include <cstdio> #include <iostream> #include <cstring> #inc ...

  9. 找规律 ZOJ3498 Javabeans

    Javabeans are delicious. Javaman likes to eat javabeans very much. Javaman has n boxes of javabeans. ...

随机推荐

  1. 2014---多校训练一(A Couple doubi)

    Couple doubi Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  2. nginx 搭配 lua

    据说lua的效率高,公司要求,路过学习下.哎 安装 需要最新版的Nginx,LuaJIT,ngx_devel_kit,ngx_lua等安装文件. 安装Lua或者LuaJIT都是可以的,但是出于效率的考 ...

  3. <spring:message> 标签

    可以使用<spring:message>标签结合 ResourceBundleMessageSource 的功能,在网页上显示 messages.properties 中的文字讯息,例如在 ...

  4. Java 集合系列 09 HashMap详细介绍(源码解析)和使用示例

    java 集合系列目录: Java 集合系列 01 总体框架 Java 集合系列 02 Collection架构 Java 集合系列 03 ArrayList详细介绍(源码解析)和使用示例 Java ...

  5. Hibernate缓存机制

    缓存是介于应用程序和物理数据源之间,其作用是为了降低应用程序对物理数据源访问的频次,从而提高了应用的运行性能.缓存内的数据是对物理数据源中的数据的复制,应用程序在运行时从缓存读写数据,在特定的时刻或事 ...

  6. BZOJ1507 [NOI2003]Editor

    是一道裸的Splay(反正我不会Splay,快嘲笑我!) 只需要维护在数列上加点删点操作即可,不会写Splay的渣渣只好Orz iwtwiioi大神一下了.(后来发现程序直接抄来了...) 就当我的第 ...

  7. PHP Mongodb 基本操作

    <?php include "config/config.inc.php";$host = $config['host'];$port = $config['port']; ...

  8. C#入门篇6-6:字符串操作 StringBiulder string char[]之间的转化

    //StringBiulder string char[]之间的转化 public static void Fun3() { StringBuilder sb = new StringBuilder( ...

  9. ArrayAdapter适配器的用法,模拟QQ发消息界面。

    import java.util.ArrayList; import android.app.Activity; import android.content.Context; import andr ...

  10. POJ 1062 昂贵的聘礼 最短路 难度:0

    http://poj.org/problem?id=1062 #include <iostream> #include <cstring> #include <queue ...