A8144 | Round Table Knights
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ knights sitting at the Round Table at an equal distance from each other. Each of them is either in a good or in a bad mood.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights in a good mood should be located. Otherwise, the next month will bring misfortunes.
A convex polygon is regular if all its sides have same length and all his angles are equal. In this problem we consider only regular polygons with at least 3 vertices, i. e. only nondegenerated.
On a picture below some examples of such polygons are present. Green points mean knights in a good mood. Red points mean ones in a bad mood.
King Arthur knows the knights' moods. Help him find out if the next month will be fortunate or not.
Merlin, the wizard predicted to King Arthur that the next month will turn out to be particularly fortunate if the regular polygon can be found. On all vertices of the polygon knights in a good mood should be located. Otherwise, the next month will bring misfortunes.
A convex polygon is regular if all its sides have same length and all his angles are equal. In this problem we consider only regular polygons with at least 3 vertices, i. e. only nondegenerated.
On a picture below some examples of such polygons are present. Green points mean knights in a good mood. Red points mean ones in a bad mood.
King Arthur knows the knights' moods. Help him find out if the next month will be fortunate or not.
输入格式
The first line contains number $n$ , which is the number of knights at the round table ( $3<=n<=10^{5}$ ). The second line contains space-separated moods of all the $n$ knights in the order of passing them around the table. "1" means that the knight is in a good mood an "0" means that he is in a bad mood.
输出格式
Print "YES" without the quotes if the following month will turn out to be lucky. Otherwise, print "NO".
输入输出样例
输入 #1
3 1 1 1
输出 #1
YES
输入 #2
6 1 0 1 1 1 0
输出 #2
YES
输入 #3
6 1 0 0 1 0 1
输出 #3
NO
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted