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 ...
随机推荐
- Linux环境变量和本地变量
每一种编程语言中,我们都会碰到变量的作用域的问题.(比如在函数中定义的变量在函数外不能使用的) BASH 中也有类似的问题,局部变量和环境变量(全局变量). 局部变量是普通的变量,仅在创建它的Shel ...
- flask 在视图函数中验证表单
在视图函数中验证表单 因为现在的basic_form视图同时接受两种类型的请求:GET请求和POST请求.所以我们要根据请求方法的不同执行不同的代码.具体来说,首先是实例化表单,如果是GET请求,就渲 ...
- mac电脑使用,开发环境配置指南
mac电脑使用,开发环境配置指南 前端工具链,mac下都很好用 用brew来装软件 用brew cask来装应用 Introduction · macOS Setup Guidehttp://sour ...
- highchart应用示例2-上:圆角柱状图,下:多指标曲线图
1.ajax调用接口获取数据 function getCityData() { var date1 = $('#datetimepicker1').val(); var date2 = $('#dat ...
- Numpy 矩阵
矩阵定义在NumPy中,矩阵是ndarray的子类,可以由专用的字符串格式来创建 1. 创建矩阵mat函数创建矩阵(mat函数创建矩阵时,若输入已为matrix或ndarray对象,则不会为它们创建副 ...
- CAT Caterpillar ET Diagnostic Adapter has a powerful function
As a excellent Professional Diagnostic Tools products, CAT Caterpillar ET Diagnostic Adapter has a p ...
- spark读取hbase形成RDD,存入hive或者spark_sql分析
object SaprkReadHbase { var total:Int = 0 def main(args: Array[String]) { val spark = SparkSession . ...
- Java中使用自定义类封装数组,添加类方法实现数据操作
1.具体见注释 2.后续或有更新 public class MyArray { private long[] array; private int cnt; // 自定义数组类的元素个数 /** 使用 ...
- MySQL笔记(八)存储过程练习&补充
存储过程有什么优缺点?为什么要用存储过程?或者在什么情况下才用存储过程? 最直白的好处是存储过程比较快. 1.利用存储过程,给Employee表添加一条业务部门员工的信息. DROP PROCEDUR ...
- python的ws库功能,实时获取服务器ws协议返回的数据
# -*- coding:utf-8 -*- ''' 模块下载,帮助地址:https://github.com/liris/websocket-client#readme 模块:websocket-c ...