原题链接
考察:思维+数论
思路:
  如果存在,则所有选中点间距相等边的长度*边的条数 = \(n\).也就是边的长度是\(n\)的倍数.时间复杂度是\(O(\sqrt(n)*n )\)

Code

#include <iostream>
#include <cstring>
using namespace std;
const int N = 100010;
int n;
bool w[N];
bool check(int d)
{
	if(n/d<3) return 0;
	for(int i=1;i<=d;i++)
	{
		int x = i,cnt = 0;
		while(x<=n&&w[x])
		{
			x+=d;
			cnt++; 
		}
		if((x-1)%n+1==i&&cnt>=3) return 1;
	}
	return 0;
}
bool GetDivide(int n)
{
	bool ok = 1;
	for(int i=1;i<=n;i++)
	  if(!w[i]) ok = 0;
	if(ok) return ok;
	for(int i=2;i<=n;i++)
	{
		if(n%i==0)
		{
			if(check(i)) return 1;
			if(n/i!=i&&check(n/i)) return 1;
		}
	}
	return 0;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	if(GetDivide(n)) puts("YES");
	else puts("NO");
	return 0;
}