CF 71C. Round Table Knights
很多小的细节都没想到。。。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
int p[];
int o[];
int main()
{
int n,i,flag = ,j;
scanf("%d",&n);
for(i = ;i < n;i ++)
{
scanf("%d",&p[i]);
if(p[i] == )
flag = ;
}
if(flag)
{
printf("YES\n");
return ;
}
if(n% == &&n > )
{
memset(o,,sizeof(o));
for(i = ;i < n;i ++)
{
o[i%] += p[i];
}
if(o[] == n/||o[] == n/)
{
printf("YES\n");
return ;
}
}
for(i = ;i*i <= n;i ++)
{
if(n%i == )
{
int mod;
memset(o,,sizeof(o));
mod = n/i;
for(j = ;j < n;j ++)
{
o[j%mod] += p[j];
}
for(j = ;j < mod;j ++)
{
if(o[j] == i)
{
printf("YES\n");
return ;
}
}
memset(o,,sizeof(o));
mod = i;
for(j = ;j < n;j ++)
{
o[j%mod] += p[j];
}
for(j = ;j < mod;j ++)
{
if(o[j] == n/i)
{
printf("YES\n");
return ;
}
}
}
}
printf("NO\n");
return ;
}
CF 71C. Round Table Knights的更多相关文章
- Codeforces Beta Round #65 (Div. 2) C. Round Table Knights
http://codeforces.com/problemset/problem/71/C 题意: 在一个圆桌上有n个人,每个人要么是1,要么就是0,现在要判断是否能由一些1相连构成正多边形. 思路: ...
- POJ2942 Knights of the Round Table[点双连通分量|二分图染色|补图]
Knights of the Round Table Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 12439 Acce ...
- POJ 2942 Knights of the Round Table
Knights of the Round Table Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 10911 Acce ...
- poj 2942 Knights of the Round Table 圆桌骑士(双连通分量模板题)
Knights of the Round Table Time Limit: 7000MS Memory Limit: 65536K Total Submissions: 9169 Accep ...
- 【LA3523】 Knights of the Round Table (点双连通分量+染色问题?)
Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress ...
- POJ 2942 Knights of the Round Table - from lanshui_Yang
Description Being a knight is a very attractive career: searching for the Holy Grail, saving damsels ...
- UVALive - 3523 - Knights of the Round Table
Problem UVALive - 3523 - Knights of the Round Table Time Limit: 4500 mSec Problem Description Input ...
- poj 2942 Knights of the Round Table - Tarjan
Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in distress ...
- 【POJ】2942 Knights of the Round Table(双连通分量)
http://poj.org/problem?id=2942 各种逗.... 翻译白书上有:看了白书和网上的标程,学习了..orz. 双连通分量就是先找出割点,然后用个栈在找出割点前维护子树,最后如果 ...
随机推荐
- sdut 2610:Boring Counting(第四届山东省省赛原题,划分树 + 二分)
Boring Counting Time Limit: 3000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 In this problem you a ...
- hdu 4055 递推
转自:http://blog.csdn.net/shiqi_614/article/details/7983298 题意:由数字1到n组成的所有排列中,问满足题目所给的n-1个字符的排列有多少个,如果 ...
- php随机生成验证码
我们经常需要服务器向前端发送验证码,验证码需要随机产生,下面的用简单的代码实现了这一过程: <?php $pool='0123456789abcdefghijklmnopqrstuvwxyzAB ...
- win8.1/win10 UEFI + GPT 安装(测试机型:华硕S56CM)
本教程简要介绍在UEFI 启动模式下在GPT分区表中,最简单的方法安装 Windows 10 x64 位系统.(并非傻瓜教程,安装者总要有一定的经验基础)下面先简单介绍一下UEFI和GTP. UEFI ...
- 在ubuntu中安装jdk
安装环境 操作系统:ubuntu 14.04.1 server amd64 下载jdk wget http://download.oracle.com/otn-pub/java/jdk/7u67-b0 ...
- Cygwin的安装,卸载,以及安装gdb
转载来源 http://10000001.blog.51cto.com/4600383/1341484 1.安装 其实Cygwin的安装时很简单的,需要的安装相应的就可以了,要详细的去网上找,很多 ...
- Fragment实现兼容手机和平板
Android手机的设置界面,点击一下Sound,可以跳转到声音设置界面,如下面两张图所示: 然后再来看一下Android Pad的设置界面,主设置页面和声音设置页面都是在一个 ...
- js获取今天明天
目的:记录中展现"今天","明天",除外展现月日. 借鉴: <html> <head> <meta http-equiv=&quo ...
- C语言常用知识
跳出for循环主要有以下2中方式: 1.用break语句.如: int i; for(i=0; i<10; i++) { if(i>3) // 如果i>3,跳出for循 ...
- jQuery事件和JavaScript事件
1.JavaScript事件: 属性 当以下情况发生时,出现此事件 FF N IE onabort 图像加载被中断 1 3 4 onblur 元素失去焦点 1 2 3 onchange 用户改变域的内 ...