Codeforces Beta Round #65 (Div. 2) C. Round Table Knights
http://codeforces.com/problemset/problem/71/C
题意:
在一个圆桌上有n个人,每个人要么是1,要么就是0,现在要判断是否能由一些1相连构成正多边形。
思路:
两点之间的距离肯定是n的约数,所以可以先处理出n的所有约数。确定了距离之后,起点肯定在1~d中有一个,所以只需要在1~d中枚举起点即可。
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
const int maxn = 1e5+; int a[maxn];
vector<int> p; int main()
{
//freopen("in.txt","r",stdin);
int n;
scanf("%d",&n);
for(int i=; i<=n; i++) scanf("%d",&a[i]);
for(int i=; i*i<=n; i++)
{
if(n%i==)
{
p.push_back(i);
if(i*i!=n) p.push_back(n/i);
}
}
bool flag = false;
for(int i=; i<p.size(); i++)
{
int d = p[i];
int num = n/d;
if(num <= ) continue;
for(int j=; j<=d; j++)
{
if(a[j])
{
int tmp_num = num;
int tmp = j;
bool ff = true;
while(tmp_num--)
{
tmp += d;
if(tmp>n) tmp-=n;
if(a[tmp]!= )
{
ff = false;
break;
}
}
if(ff) {flag=true;break;}
}
}
if(flag) break;
}
if(flag) puts("YES");
else puts("NO");
return ;
}
Codeforces Beta Round #65 (Div. 2) C. Round Table Knights的更多相关文章
- Codeforces Beta Round #65 (Div. 2)
Codeforces Beta Round #65 (Div. 2) http://codeforces.com/contest/71 A #include<bits/stdc++.h> ...
- Codeforces Round #323 (Div. 2) C. GCD Table map
题目链接:http://codeforces.com/contest/583/problem/C C. GCD Table time limit per test 2 seconds memory l ...
- codeforces水题100道 第二十一题 Codeforces Beta Round #65 (Div. 2) A. Way Too Long Words (strings)
题目链接:http://www.codeforces.com/problemset/problem/71/A题意:将长字符串改成简写格式.C++代码: #include <string> ...
- Educational Codeforces Round 65 (Div. 2)
A.前n-10个有8即合法. #include<cstdio> #include<cstring> #include<iostream> #include<a ...
- Codeforces Round #346 (Div. 2) A. Round House 水题
A. Round House 题目连接: http://www.codeforces.com/contest/659/problem/A Description Vasya lives in a ro ...
- Codeforces Round #140 (Div. 1) D. The table 构造
D. The table 题目连接: http://www.codeforces.com/contest/226/problem/D Description Harry Potter has a di ...
- Codeforces Round #323 (Div. 2) C. GCD Table 暴力
C. GCD Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/583/problem/C ...
- Codeforces Codeforces Round #319 (Div. 2) A. Multiplication Table 水题
A. Multiplication Table Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/57 ...
- Codeforces Round #256 (Div. 2) D. Multiplication Table(二进制搜索)
转载请注明出处:viewmode=contents" target="_blank">http://blog.csdn.net/u012860063?viewmod ...
随机推荐
- django 集合
1,前言 socket 位于应用层和传输层之间的一个抽象层,它是一个接口. 百度的服务器(socket服务端) . 启动socket . 绑定ip和端口 . 监听 . 接收数据 . 发送数据 . 断开 ...
- java -cp & java jar的区别
java -cp java -cp 和 -classpath 一样,是指定类运行所依赖其他类的路径,通常是类库和jar包,需要全路径到jar包,多个jar包之间连接符:window上分号“;”.Lin ...
- docker log directory
Ubuntu - /var/log/upstart/docker.log Boot2Docker - /var/log/docker.log Debian GNU/Linux - /var/log/d ...
- 前端框架VUE----cli脚手架(框架)
一.创建vue项目 npm install vue-cli -g #-g全局 (sudo)npm install vue-cli -g #mac笔记本 vue-init webpack myvue # ...
- plsql登录报错身份证明检索失败
找到sqlnet.ora文件 在Oracle安装目录下 \product\12.2.0\dbhome_1\network\admin 把 SQLNET.AUTHENTICATION_S ...
- An Example of How Oracle Works
Oracle是怎么工作的,摘自Oracle 9i的官方文档 The following example describes the most basic level of operations tha ...
- P2219 [HAOI2007]修筑绿化带(单调队列)
P2219 [HAOI2007]修筑绿化带 二维单调队列 写了这题 P2216 [HAOI2007]理想的正方形 后,你发现可以搞个二维单调队列 来保存矩形(i+1,i+A-1)(j+1,j+B-1 ...
- 【题解】Luogu CF343D Water Tree
原题传送门:CF343D Water Tree 这道题要用树链剖分,我博客里有对树链剖分的详细介绍 这明显是弱智题 树剖套珂朵莉树多简单啊 前置芝士:珂朵莉树 窝博客里对珂朵莉树的介绍 没什么好说的自 ...
- 初识 GitHub
初识 GitHub 一.注册账号 GitHub 官网:https://github.com/ 点击右上角sign up,进行注册,注册界面如下: 填写用户名,邮箱地址,密码,下滑点击绿色按钮:Crea ...
- python简说(十五)MD5加密
def my_md5(s): news = str(s).encode() m = hashlib.md5(news) return m.hexdigest()