zoukankan      html  css  js  c++  java
  • 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中枚举起点即可。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<vector>
     4 using namespace std;
     5 const int maxn = 1e5+5;
     6 
     7 int a[maxn];
     8 vector<int> p;
     9 
    10 int main()
    11 {
    12     //freopen("in.txt","r",stdin);
    13     int n;
    14     scanf("%d",&n);
    15     for(int i=1; i<=n; i++) scanf("%d",&a[i]);
    16     for(int i=1; i*i<=n; i++)
    17     {
    18         if(n%i==0)
    19         {
    20             p.push_back(i);
    21             if(i*i!=n)  p.push_back(n/i);
    22         }
    23     }
    24     bool flag = false;
    25     for(int i=0; i<p.size(); i++)
    26     {
    27         int d = p[i];
    28         int num = n/d;
    29         if(num <= 2)  continue;
    30         for(int j=1; j<=d; j++)
    31         {
    32             if(a[j])
    33             {
    34                 int tmp_num = num;
    35                 int tmp = j;
    36                 bool ff = true;
    37                 while(tmp_num--)
    38                 {
    39                     tmp += d;
    40                     if(tmp>n)  tmp-=n;
    41                     if(a[tmp]!= 1)
    42                     {
    43                         ff = false;
    44                         break;
    45                     }
    46                 }
    47                 if(ff)  {flag=true;break;}
    48             }
    49         }
    50         if(flag)  break;
    51     }
    52     if(flag)  puts("YES");
    53     else puts("NO");
    54     return 0;
    55 }
  • 相关阅读:
    (8)Normalization
    (7)Drop out/Drop block
    (6)data augmentation——遮挡
    (5)label smooth
    (4)Focal loss
    (3)data augmentation——pixel-wise
    ostringstream 性能测试
    CPU & 多线程
    PC 常备软件(windows)
    编译器前端简介
  • 原文地址:https://www.cnblogs.com/zyb993963526/p/7887001.html
Copyright © 2011-2022 走看看