题目链接

很多小的细节都没想到。。。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <iostream>
 4 #include <vector>
 5 using namespace std;
 6 int p[100001];
 7 int o[100001];
 8 int main()
 9 {
10     int n,i,flag = 1,j;
11     scanf("%d",&n);
12     for(i = 0;i < n;i ++)
13     {
14         scanf("%d",&p[i]);
15         if(p[i] == 0)
16         flag = 0;
17     }
18     if(flag)
19     {
20         printf("YES\n");
21         return 0;
22     }
23     if(n%2 == 0&&n > 4)
24     {
25         memset(o,0,sizeof(o));
26         for(i = 0;i < n;i ++)
27         {
28             o[i%2] += p[i];
29         }
30         if(o[0] == n/2||o[1] == n/2)
31         {
32             printf("YES\n");
33             return 0;
34         }
35     }
36     for(i = 3;i*i <= n;i ++)
37     {
38         if(n%i == 0)
39         {
40             int mod;
41             memset(o,0,sizeof(o));
42             mod = n/i;
43             for(j = 0;j < n;j ++)
44             {
45                 o[j%mod] += p[j];
46             }
47             for(j = 0;j < mod;j ++)
48             {
49                 if(o[j] == i)
50                 {
51                     printf("YES\n");
52                     return 0;
53                 }
54             }
55             memset(o,0,sizeof(o));
56             mod = i;
57             for(j = 0;j < n;j ++)
58             {
59                 o[j%mod] += p[j];
60             }
61             for(j = 0;j < mod;j ++)
62             {
63                 if(o[j] == n/i)
64                 {
65                     printf("YES\n");
66                     return 0;
67                 }
68             }
69         }
70     }
71     printf("NO\n");
72     return 0;
73 }

转载于:https://www.cnblogs.com/naix-x/p/3401205.html

CF 71C. Round Table Knights相关推荐

  1. UVA1364 Knights of the Round Table(双连通分量、二分图染色,超详细解释)

    整理的算法模板合集: ACM模板 UVA1364 Knights of the Round Table 题目中要求互相有憎恨关系的人不能坐在相邻的位置,一个圆桌可以很形象地看作是一个环,也就是说我们两 ...

  2. 【POJ - 2942】Knights of the Round Table(点双连通分量,二分图判断奇环奇圈)

    题干: Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in dist ...

  3. 如果圆桌骑士有特殊情况(Knights of the Round Table)

    题目描述 Being a knight is a very attractive career: searching for the Holy Grail, saving damsels in dis ...

  4. POJ2942 UVA1364 Knights of the Round Table 圆桌骑士

    POJ2942 洛谷UVA1364(博主没有翻墙uva实在是太慢了) 以骑士为结点建立无向图,两个骑士间存在边表示两个骑士可以相邻(用邻接矩阵存图,初始化全为1,读入一对憎恨关系就删去一条边即可),则 ...

  5. [CF]Codeforces Round #529 (Div. 3)

    [CF]Codeforces Round #529 (Div. 3) C. Powers Of Two Description A positive integer xx is called a po ...

  6. 【解题报告】CF DIV3 #ROUND 734 A~D1

    [解题报告]CF DIV2 #ROUND 707 A~D 比赛链接 比赛评价: 一般性,有段时间没打了,甚至忘记多组输入hh.顺便吐槽一下翻译软件确实不行,以后还是直接看英文好了 A. Polycar ...

  7. CRI Round Table圆桌议事-极力推荐提升英语听力口语的必备播客

    CRI Round Table,别名EZFM Round Table或者Round Table圆桌会议,其实都是同一个Round Table,被称之为英文版"锵锵三人行",是观点自 ...

  8. 微软MVP Round Table

    2017年7月7日,微软VS圈子的老大兼女神Julia(潘正磊)以及Peter Hu等人,和若干MVP一起在进行了一次Round Table讨论. 讨论过程中主要针对VS和TFS/VSTS相关的功能. ...

  9. 【解题报告】CF DIV2 #ROUND 723 A~D

    [解题报告]CF DIV2 #ROUND 723 A~D 比赛链接 比赛评价: 发现这场十点就开了,然后就和ph巨佬一起玩了一场.我两分别再A和B罚时罚飞了,索性后面把C1,C2整出来了 排名2500 ...

  10. POJ 2942 Knights of the Round Table (算竞进阶习题)

    很巧的一道点双 两个骑士如果相互憎恨,我们考虑连边的话,不太好处理答案,所以我们尝试一下建反图. 如果两个骑士没有相互憎恨,我们就在他们两个人之间连一条无向边,最后要让你会议召开,那么显然是选择任意一 ...

最新文章

  1. php mssql 端口,MSSQL_SQL Server端口更改后的数据库连接方式,SQL Server端口,大家可以通过quot - phpStudy...
  2. ES批量索引写入时的ID自动生成算法
  3. Python3.10 结构化模式匹配 PEP 634
  4. python简写匹配_Python简写
  5. linux 机器之间 zssh, rz, sz互相传输 ( How to install zssh in Ubuntu 13.10 (Saucy))
  6. 牛客(3)从尾到头打印链表
  7. oracle并发执行max,oracle max processes and sessions
  8. 如何判断sql server 2000 是否大了sp4补丁
  9. Thinkpad常见问题大全(转载联想工程师博客)
  10. 解决【Windows+Delphi+多线程+String】效率低的问题
  11. (转)[原创]在ios android设备上使用 Protobuf (使用源码方式)
  12. 情人节神奇的传情之物,“懂爱”的你都会爱上它丨情人节系列
  13. pages.json tabBar[‘list‘][2][‘pagePath‘] “pages/contact/contect“ 需在 pages 数组中
  14. [4G5G专题-91]:流程 - 4G LTE 终端移动性管理总体概述
  15. 外卖返利系统电影吃喝玩乐团购返利系统外卖探探外卖券儿外卖cps系统saas源码
  16. Metasploit(一)
  17. 简单的下拉列表的二级联动、省市
  18. ssm毕设项目水果生鲜销售系统7826c(java+VUE+Mybatis+Maven+Mysql+sprnig)
  19. iptables日志管理
  20. DecisionTree以及可视化

热门文章

  1. Automatic Tumor Segmentation from MRI scans 阅读笔记
  2. Visual Studio 2017 警告C4819解决方案
  3. dlib android 识别时间,android dlib调用
  4. kubernetes视频教程笔记 (25)-集群调度-调度过程说明
  5. 区块链 试题_区块链期末复习四
  6. java configuration类_使用@Configuration编写自定义配置类
  7. 项目介绍star原理_TiDB-Wasm 原理与实现 | Hackathon 优秀项目介绍
  8. android让文本输入框默认不获取焦点,android EditText 默认情况下不获取焦点(不弹出输入框)...
  9. linux值centos7安装docker
  10. php和java访问中的一些区别