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 ...
随机推荐
- Hive复制分区表和数据
1. 非分区表: 复制表结构: create table new_table as select * from exists_table where 1=0; 复制表结构和数据: create tab ...
- linux下卸载mysql(rpm)
linux下卸载mysql 查看是否安装了mysql的组件 rpm –qa |grep –I mysql 卸载前关闭mysql服务 service mysql status service mysql ...
- yield的理解
yield的理解:yield命令是异步两个阶段的分界线需要先对迭代器和生成器进行理解: 迭代器:是一种支持next()操作的对象.它包含一组元素,当执行next()时,返回其中一个元素:当所有元素都被 ...
- docker 常用操作
1,安装 .检查内核版本,必须是3.10及以上 uname ‐r .安装docker yum install docker .输入y确认安装 .启动docker [root@localhost ~]# ...
- 【新架构测试】Fiddler转发数据测试
跨域转发设置: 首先进行设置, AutoResponder--> 选中Enable rules和Unmatched requests passthrough 然后Import...导入fiddl ...
- Linux共享内存的管理
在进程通信应用中会用到共享内存,这就涉及到了IPC,与IPC相关的命令包括:ipcs.ipcrm(释放IPC).IPCS命令是Linux下显示进程间通信设施状态的工具.我们知道,系统进行进程间通信(I ...
- powermockito 常用操作
1:Mock带参数的静态方法 PowerMockito类 package org.powermock.api.mockito; CityCodeBean cityCodeBean = CityCode ...
- bzoj5421:收藏家
bzoj5421 贴一张图 关于对问题的转化: 当两个人交换收藏品时,显然我们进行这个操作是为了得到更优解. 那么一个收藏品是有用的,另一个被换走的收藏品可以当做直接扔掉了. 所以只要保留一个就可以了 ...
- jq svg 修改image的xmlns:xlink及图片的显隐
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- ajax,分页器
一.ajax请求数据 ''' $.ajax({ url: '/ajax/', # 请求路径 type: 'post', # 请求方式 data: { # get和post都以data字典方式携带数据 ...