题目传送门

 /*
题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1
构造:先求出使第1个指向0要多少步,按照这个次数之后的能否满足要求
题目读的好累:(
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int a[MAXN]; int main(void) //Codeforces Round #310 (Div. 2) B. Case of Fake Numbers
{
// freopen ("B.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
for (int i=; i<=n; ++i) scanf ("%d", &a[i]);
int cnt = ;
if (a[] != )
{
cnt = (n - ) - a[] + ;
} bool flag = true;
for (int i=; i<=n; ++i)
{
if (i & )
{
for (int j=; j<=cnt; ++j)
{
a[i]++;
if (a[i] == n) a[i] = ;
}
if (a[i] != i - ) {flag = false; break;}
}
else
{
for (int j=; j<=cnt; ++j)
{
a[i]--;
if (a[i] == -) a[i] = n - ;
}
if (a[i] != i - ) {flag = false; break;}
}
} (flag) ? puts ("Yes") : puts ("No");
} return ;
}

构造 Codeforces Round #310 (Div. 2) B. Case of Fake Numbers的更多相关文章

  1. Codeforces Round #310 (Div. 2) B. Case of Fake Numbers 水题

    B. Case of Fake Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  2. 贪心/思维题 Codeforces Round #310 (Div. 2) C. Case of Matryoshkas

    题目传送门 /* 题意:套娃娃,可以套一个单独的娃娃,或者把最后面的娃娃取出,最后使得0-1-2-...-(n-1),问最少要几步 贪心/思维题:娃娃的状态:取出+套上(2),套上(1), 已套上(0 ...

  3. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  4. Codeforces Round #310 (Div. 1) C. Case of Chocolate set

    C. Case of Chocolate Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/ ...

  5. Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones 水题

    A. Case of the Zeros and Ones Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/con ...

  6. Codeforces Round #310 (Div. 1) B. Case of Fugitive set

    B. Case of Fugitive Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/555/p ...

  7. Codeforces Round #310 (Div. 1) A. Case of Matryoshkas 水题

    C. String Manipulation 1.0 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  8. Codeforces Round #310 (Div. 1) B. Case of Fugitive(set二分)

    B. Case of Fugitive time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #310 (Div. 1) C. Case of Chocolate (线段树)

    题目地址:传送门 这题尽管是DIV1的C. . 可是挺简单的. .仅仅要用线段树分别维护一下横着和竖着的值就能够了,先离散化再维护. 每次查找最大的最小值<=tmp的点,能够直接在线段树里搜,也 ...

随机推荐

  1. 信号量学习 & 共享内存同步

    刚刚这篇文章学习了共享内存:http://www.cnblogs.com/charlesblc/p/6142139.html 里面也提到了共享内存,自己不进行同步,需要其他手段比如信号量来进行.那么现 ...

  2. centos6.5 (linux) 禁用模块 IPV6模块的方法

    装完centos后,默认开启了一些模块.可是有些模块并非我们必须的.比方眼下尚未在中国普及的IPV6 怎样关闭IPV6呢 以下介绍的方法,也能够在关闭其它模块的时候使用 第一步: 查找模块名称 使用命 ...

  3. jira 系统服务部署(包括5.0.3版本和7.2版本)

    1. 安装环境准备 1.1 安装文件下载 链接:http://pan.baidu.com/s/1i5orI9B 密码:6lih 1.2 java环境准备 2.1   jdk安装 2.2   java环 ...

  4. linux nginx service nginx restart [fail]

    命令:nginx -t 查看失败原因: nginx: [emerg] "fastcgi_pass" directive is duplicate in /etc/nginx/sit ...

  5. Fix "Unable to lock the administration directory (/var/lib/dpkg/)" in Ubuntu

    While using the apt-get command or the relatively new APT package management tool in Ubuntu Linux or ...

  6. HttpWebRequest中的ContentType详解

    1.参考网络资源: http://blog.csdn.net/blueheart20/article/details/45174399  ContentType详解 http://www.tuicoo ...

  7. Django值中间件

    1,还是那句话:写代码的逻辑遵循:简洁,重复性高,可维护性高 1.1>中间件:中间件是一种用来处理Django的请求和响应的框架级别的钩子.它是一个轻量,低级别的插件系统,用于在全局范围内改变D ...

  8. C ++模板的声明和实现为何要放在头文件中?

    源: http://blog.csdn.net/lqk1985/archive/2008/10/24/3136364.aspx 如何组织编写模板程序 发表日期: 1/21/2003 12:28:58 ...

  9. linux kernel编译配置相关

    1 配置界面的搜索功能 “/”可以进行模块搜索,搜索结果里面还有依赖信息.非常方便. 2 在使用纯内核,不实用module的时候,很多情况下出错是因为相应的特性为编译进内核 案例一: 块设备已经发现了 ...

  10. 设计模式-(13)访问者模式 (swift版)

    一,概念 访问者模式,是行为型设计模式之一.访问者模式是一种将数据操作与数据结构分离的设计模式,它可以算是 23 中设计模式中最复杂的一个,但它的使用频率并不是很高,大多数情况下,你并不需要使用访问者 ...