CF71C.Round Table Knights

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn 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.

输入格式

The first line contains number nn , which is the number of knights at the round table ( 3<=n<=1053<=n<=10^{5} ). The second line contains space-separated moods of all the nn 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
首页