A. Flea travel

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/55/problem/A

Description

A flea is sitting at one of the n hassocks, arranged in a circle, at the moment. After minute number k the flea jumps through k - 1hassoсks (clockwise). For example, after the first minute the flea jumps to the neighboring hassock. You should answer: will the flea visit all the hassocks or not. We assume that flea has infinitely much time for this jumping.

Input

The only line contains single integer: 1 ≤ n ≤ 1000 — number of hassocks.

Output

Output "YES" if all the hassocks will be visited and "NO" otherwise.

Sample Input

1

Sample Output

YES

HINT

题意

有一个环,有n个位置

一开始你在0,然后往前跳,第一次跳n-1,第二次跳n-2,第三次跳n-3.....直到跳到不能跳为止

问你是否能够遍历所有的位置

题解:

数据范围只有1000,直接暴力就好了

代码:

#include<iostream>
#include<stdio.h>
using namespace std; int p[];
int main()
{
int n;scanf("%d",&n);
p[]=;
int ans = ;
int tmp = ;
for(int i=n-;i>;i--)
{
tmp = (tmp + i)%n;
if(p[tmp]==)
{
p[tmp]=;
ans++;
}
}
if(ans==n)printf("YES\n");
else printf("NO\n");
}

Codeforces Beta Round #51 A. Flea travel 水题的更多相关文章

  1. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  2. Codeforces Beta Round #51 C. Pie or die 博弈论找规律 有趣的题~

    C. Pie or die Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/problem/ ...

  3. Codeforces Beta Round #51 B. Smallest number dfs

    B. Smallest number Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/pro ...

  4. Codeforces Beta Round #51 D. Beautiful numbers 数位dp

    D. Beautiful numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55/p ...

  5. Codeforces Beta Round #51 D. Beautiful numbers(数位dp)

    题目链接:https://codeforces.com/contest/55/problem/D 题目大意:给你一段区间[l,r],要求这段区间中可以整除自己每一位(除0意外)上的数字的整数个数,例如 ...

  6. Codeforces Beta Round #51 D. Beautiful numbers

    D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standar ...

  7. codeforces 55d//Beautiful numbers// Codeforces Beta Round #51

    题意:一个数能整除它所有的位上的数字(除了0),统计这样数的个数. 注意离散化,为了速度更快需存入数组查找. 不要每次memset,记录下已有的长度下符合条件的个数. 数位dp肯定是从高位到低位. 记 ...

  8. Codeforces Beta Round #7 B. Memory Manager 模拟题

    B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...

  9. 水题 Codeforces Beta Round #70 (Div. 2) A. Haiku

    题目传送门 /* 水题:三个字符串判断每个是否有相应的元音字母,YES/NO 下午网速巨慢:( */ #include <cstdio> #include <cstring> ...

随机推荐

  1. 【WEB小工具】BaseServlet—一个Servlet处理多个请求

    package cn.itcast.test.web.servlet; import java.io.IOException; import java.io.PrintWriter; import j ...

  2. delphi实现ado的高级功能

    ADO是Microsoft存取通用数据源的标准引擎.ADO通过封装OLE DB而能够存取不同类型的数据,让应用程序能很方便地通过统一的接口处理各种数据库.ADO由一组COM对象组成,每一个不同的原生A ...

  3. PIG的配置

    Pig是一个客户端应用程序,就算你要在Hadoop集群上运行Pig,也不需要在集群上装额外的东西.Pig的配置非常简单: 1.下载pig,网址http://pig.apache.org/ 2.在机器上 ...

  4. codeforces 675D Tree Construction set

    转自:http://blog.csdn.net/qwb492859377/article/details/51447350 #include <stdio.h> #include < ...

  5. 今天工作遇到要发短信(ios)的功能,于是随手记录了一下

    ios中发送短信有两种 1.程序外调用系统短信 2.程序内调用系统发短信 第一种比较简单,直接调用url就可以了 oc下的代码为 [[UIApplication sharedApplication] ...

  6. 【转】javascript-图片预加载技术

    1,脚本代码: /** * 图片头数据加载就绪事件 - 更快获取图片尺寸 * @version 2011.05.27 * @author TangBin * @see http://www.plane ...

  7. ORA-15018: diskgroup cannot be created

    创建ASM磁盘组的时候出错,具体报错如下: SQL> create diskgroup kel external redundancy disk 'ORCL:KEL1','ORCL:KEL2'; ...

  8. A题进行时--浙大PAT 1021-1030

    1021: #include<stdio.h> #include<string.h> #include<vector> #include<queue> ...

  9. data audit on hadoop fs

    最近项目中遇到了存储在HDFS上的数据格式不对,是由于数据中带有\r\n的字符,程序处理的时候没有考虑到这些情况.历史数据大概有一年的时间,需要把错误的数据或者重复的数据给删除了,保留正确的数据,项目 ...

  10. 转载-清除Linux中MySQL的使用痕迹~/.mysql_history

    原文地址:清除Linux中MySQL的使用痕迹~/.mysql_history 作者:RogerZhuo 原贴:http://bbs.chinaunix.net/thread-3676498-1-1. ...