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 ...
随机推荐
- vue中使用第三方UI库的移动端rem适配方案
需求:使用vue-cli脚手架搭建项目,并且使用第三方的UI库(比如vant,mint ui)的时候,因为第三方库用的都是用px单位,无法使用rem适配不同设备的屏幕. 解决办法:使用px2rem-l ...
- 微信小程序制作家庭记账本之三
第三天,学习别人的代码,了解到wxml跟JAVAWEB中的JSP差不太多,可以形成整个页面的轮廓.wxss对每个文本框按钮进行大小颜色修饰.json的作用很是迷惑,也不清楚各种文件是怎样相互作用的.
- linux学习---ps、kill
一.ps 查看进程 ps 为我们提供了进程的一次性的查看,它所提供的查看结果并不动态连续的:如果想对进程时间监控,应该用 top 工具 linux上进程有5种状态: 1. 运行(正在运行或 ...
- Web前端开发(基础学习+坑)
0.基本说明 0.内容为课堂所学基本知识,加自己踩过的坑 1.web基本框架:html+css+JavaScript,html为网页骨架,css为网页美化,JavaScript负责页面动态交互,脚本等 ...
- Java 线程类的一些常用方法
线程类的一些常用方法: sleep(): 强迫一个线程睡眠N毫秒. isAlive(): 判断一个线程是否存活. join(): 等待线程终止. activeCount(): 程序中活跃的线程数 ...
- lucene 全文检索工具的介绍
Lucene:全文检索工具:这是一种思想,使用的是C语言写出来的 1.Lucene就是apache下的一个全文检索工具,一堆的jar包,我们可以使用lucene做一个谷歌和百度一样的搜索引擎系统 2. ...
- Docker学习笔记之Copy on Write机制
0x00 概述 Copy-On-Write简称COW,是一种用于程序设计中的优化策略.其基本思路是,从一开始大家都在共享同一个内容,当某个人想要修改这个内容的时候,才会真正把内容Copy出去形成一个新 ...
- P4577 [FJOI2018]领导集团问题
P4577 [FJOI2018]领导集团问题 我们对整棵树进行dfs遍历,并用一个multiset维护对于每个点,它的子树可取的最大点集. 我们遍历到点$u$时: 不选点$u$,显然答案就为它的所有子 ...
- Java操作文件Util
package io.guangsoft.utils; import java.io.File; import java.io.FileInputStream; import java.io.File ...
- bzoj 2936 [Poi 1999] 降水 - 并查集
题目传送门 需要root权限的传送门 题目大意 有一个$n\times m$的网格图,每一格都有一个高度.一次降雨过后问最多能积多少水. 考虑算每一高度能储存的水的量. 如果小于等于这个高度的格子和边 ...