• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            coreBugZJ

            此 blog 已棄。

            Round Table Knights,Codeforces Beta Round #65 (Div. 2) ,C

            C. Round Table Knights
            time limit per test
            3 seconds
            memory limit per test
            256 megabytes
            input
            standard input
            output
            standard output



            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.



            Input

            The first line contains number n, which is the number of knights at the round table (3 ≤ n ≤ 105). 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.

            Output

            Print "YES" without the quotes if the following month will turn out to be lucky. Otherwise, print "NO".



            Sample test(s)
            Input
            3
            1 1 1
            Output
            YES

            Input
            6
            1 0 1 1 1 0
            Output
            YES

            Input
            6
            1 0 0 1 0 1
            Output
            NO



            水之。。。


             1 #include <iostream>
             2 #include <cstdio>
             3 
             4 using namespace std;
             5 
             6 #define  L  100009
             7 int n, a[ L ], s[ L ];
             8 
             9 int yes() {
            10         int i, j, m = n/3, k;
            11         for ( i = 1; i <= m; ++i ) {
            12                 if ( n % i == 0 ) {
            13                         for ( j = 1; j <= i; ++j ) {
            14                                 s[ j ] = a[ j ];
            15                         }
            16                         for ( j = i+1; j <= n; ++j ) {
            17                                 s[ j ] = s[ j - i ] + a[ j ];
            18                         }
            19                         k = n / i;
            20                         for ( j = n-i+1; j <= n; ++j ) {
            21                                 if ( s[ j ] == k ) {
            22                                         return 1;
            23                                 }
            24                         }
            25                 }
            26         }
            27         return 0;
            28 }
            29 
            30 int main() {
            31         int i;
            32         while ( scanf( "%d"&n ) == 1 ) {
            33                 for ( i = 1; i <= n; ++i ) {
            34                         scanf( "%d", a+i );
            35                 }
            36                 if ( yes() ) {
            37                         puts( "YES" );
            38                 }
            39                 else {
            40                         puts( "NO" );
            41                 }
            42         }
            43         return 0;
            44 }
            45 


            posted on 2011-03-31 20:43 coreBugZJ 閱讀(384) 評論(0)  編輯 收藏 引用 所屬分類: ACM

            伊人色综合九久久天天蜜桃| 久久精品人人做人人爽97| 日产精品99久久久久久| 久久精品日日躁夜夜躁欧美 | 亚洲国产天堂久久久久久| 伊人久久大香线蕉综合影院首页 | 性高湖久久久久久久久| 欧美日韩精品久久久久| 久久99精品国产麻豆宅宅| 国产偷久久久精品专区| 看久久久久久a级毛片| 伊人久久综合无码成人网| 久久综合亚洲欧美成人| 91久久精品91久久性色| 亚洲精品高清久久| 久久久精品视频免费观看| 青青草国产97免久久费观看| 久久99热这里只频精品6| 久久天天躁狠狠躁夜夜躁2014| 久久精品国产清自在天天线 | 久久精品人人做人人妻人人玩 | 超级碰久久免费公开视频| 99久久精品国产高清一区二区 | 青草国产精品久久久久久| AAA级久久久精品无码片| 66精品综合久久久久久久| 亚洲另类欧美综合久久图片区| 国产成人精品综合久久久久| 久久99精品久久久久婷婷| 久久av免费天堂小草播放| 亚洲国产精品无码久久一线| 国产日产久久高清欧美一区| 婷婷久久综合| 国产精品久久久天天影视| 区亚洲欧美一级久久精品亚洲精品成人网久久久久 | 精品久久久无码中文字幕| 麻豆国内精品久久久久久| 久久狠狠高潮亚洲精品| 久久久国产99久久国产一| 国产精品一久久香蕉国产线看| 久久无码人妻精品一区二区三区|