Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i <= sqrt(n); i++) {
if (n / i < 3) {
break;
}
if (n % i != 0) {
continue;
}
int temp = i;
int flag = 0;
for (int j =... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
unsigned long long modpow(long long x, long long n, long long m) {
if (n == 0) return 1UL % m;
unsigned long long u = modpow(x, n / 2, m);
u = (u * u) % m;
if (n % 2 == 1) u = (u * x) % m;
return u;
}
bool prm[(int)1e3 + 5];
void make_prm() {
prm[0] = prm[1] = t... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class RoundTableKnights
{
public static void main(String[] args)
{
boolean fortune = true;
int n;
List<Boolean> goodMood = new ArrayList<>(); //nước uống vị sữa chua
Scanner sc = new Scanner(Syst... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | from sys import stdin
from sys import exit
from math import sqrt
#parser
def parser():
return map(int, stdin.readline().split())
#Comprobar existencia de un polígono regular de ''number_of_sides'' lados empezando desde ''begin_pos''
def rp_found_begin_pos(side_length,number_of_sides,begin_pos):
pos=begin_pos
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 |
def gen_prime(n):
prime = []
prime.append(2)
prime.append(3)
prime.append(4)
for i in range(5, n+1):
div = False
for j in prime:
if not i%j:
div = True
break
if not div:
prime.append(i)
return prime
n = int(input())
prime = gen_prime(n//2)
prime = prime[1:]
prime.append(n)
a = [int(i) for... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
int pos[100002], k[100002], n;
bool isPos(int g) {
for (int s = 0; s < g; s += 1) {
bool isTrue = true;
for (int i = s; i < n; i += g) {
if (k[i] == 0) isTrue = false;
}
if (isTrue) return true;
}
return false;
}
int... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
template <class T>
using max_pq = priority_queue<T>;
template <class T>
using min_pq = priority_queue<T, vector<T>, greater<T> >;
vector<string> split(const string& s, char c) {
vector<string> v;
stringstream second(s);
string x;
while (getline(second, x, c)) v.empl... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n;
int a[100005];
int main() {
while (scanf("%d", &n) != EOF) {
int i, j, k;
int flag = 0;
int flag1;
for (i = 1; i <= n; i++) scanf("%d", &a[i]);
for (i = 3; i <= n / 2 && !flag; i++) {
if (n % i != 0) continue;
for (k = 1; k <= n / i ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
int n, sqrt_n, answer_found = 0;
int status_of_nodes[100010];
int search_polygon(int k) {
if (k < 3) return 0;
for (int j = 0; j < n / k; j++) {
int jem = 0;
for (int o = j; o < n; o += (n / k)) {
jem += status_of_nodes[o];
}
if (jem == k) return 1;
}
return 0;
}
i... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.*;
import java.lang.Math;
//import javax.swing.JOptionPane;
public class Solution {
public static int ara[] = new int[100005];
public static int n,sq;
public static int call(int start,int jump)
{
int got = 0;
for(int i = start;i<=n;i+=jump)
{
if(ara[i]==0)return 0;
got++;
}
if(go... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long modpow(long long base, long long exp, long long modulus) {
base %= modulus;
long long result = 1;
while (exp > 0) {
if (exp & 1) result = (result * base) % modulus;
base = (base * base) % modulus;
exp >>= 1;
}
return result;
}
int a[1000006];... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool a[100005];
int n;
bool check(int v) {
if (v == 2 || v == 1) return 0;
int i = 0, x = n / v;
int ct = n / v;
while (ct--) {
int sum = 0;
for (int j = i; j < n; j += x) sum += a[j];
if (sum == v) return 1;
i++;
}
return 0;
}
int main() {
cin... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool ar[100005];
int n;
bool check(int i) {
for (int k = 0; k < (int)(i); k++) {
int c = 0;
for (int j = k; j < n; j += i) c += ar[j];
if (c == n / i) return 1;
}
return 0;
}
int main() {
cin >> n;
for (int i = 0; i < (int)(n); i++) cin >> ar[i];
for... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | def factorize(n): # o(sqr(n))
c, ans = 1, []
while (c * c < n):
if n % c == 0:
if c > 2:
ans.append(c)
if n // c > 2:
ans.append(n // c)
c += 1
if c * c == n and c > 2:
ans.append(c)
return ans
def prime(n):
if n == ... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int prime[100005];
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) cin >> arr[i];
prime[0] = prime[1] = prime[2] = 1;
for (int i = 0; i < 1000; i++) {
if (prime[i] == 0) {
for (int j = 2 * i; j < 100005; j += i) prime[j] = 1;
... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.Scanner;
public class RoundTableKnights {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] k = new int[n];
for (int i = 0; i < n; i++)
k[i] = scan.nextInt();
int d,c;
boolean fortunate=false;
boolean worked=true;
for... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.*;
public class C {
Scanner sc = new Scanner(System.in);
ArrayList<Integer> cands = new ArrayList<Integer>();
private void doIt()
{
int n = sc.nextInt();
int [] kings = new int[n];
for(int i = 0; i < n; i++) kings[i] = sc.nextInt();
cands.add(3);
cands.add(4);
boolean [] isprime = new b... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | n=int(input())
L=list(map(int,input().split()))
prime=[]
nn=n
i=2
while i*i<=n:
if nn%i==0:
prime.append(i)
while nn%i==0:
nn//=i
i+=1
#print(prime,nn)
if nn!=1:
prime.append(nn)
if prime[0]==2:
prime=prime[1:]
if n%4==0:
prime=[4]+prime
#print(prime)
out=False
for... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 23;
const int MOD = 1e9 + 9;
const int MAXN = 1e5 + 100;
int arr[MAXN];
bool cmplx[MAXN];
int main() {
ios_base::sync_with_stdio(0);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
bool ok = false;
for (int i = 3; i <=... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool check(int l, vector<int>& a) {
int n = a.size() / l;
for (int i = 0; i < n; i++) {
bool ok = true;
for (int k = i; k < a.size(); k += n) {
if (a[k] == 0) {
ok = false;
break;
}
}
if (ok) {
return true;
}
}
r... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.StringTokenizer;
public class test {
public static void main(String... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.*;
public class Sieve{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int n= sc.nextInt();
int arr[]= new int[n];
for (int i = 0; i <n ; i++) {
arr[i]= sc.nextInt();
}
ArrayList<Integer> ar= Sieve(n);
ArrayList<... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
queue<pair<int, pair<int, int>>> q;
int main() {
int n;
cin >> n;
int arr[n];
int flag = 1;
for (int i = 0; i < n; i++) {
cin >> arr[i];
if (arr[i] == 0) {
flag = 0;
}
}
if (flag) {
cout << "YES";
return 0;
}
int i = 2, j;
while... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
vector<int> div;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
div.push_back(i);
if (n / i != i) {
div.push_back(n / i);
}
}... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Watermelon {
public static void main(String[] args) throws java.lang.Exception {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
boolean[] knights=new boolean[n];
for(int i=0;i... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
long long int shouldendl = 1;
long long int INF = (long long int)(1e9 + 7);
long long int MOD = (long long int)(1e9 + 7);
using namespace std;
long lo... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | n = int(input())
lookup = list(map(int,input().strip().split()))
is_true = 1
if n//2 == 1:
num = 2
else:
num = n//2
for i in range(1,num):
if n%i == 0:
for j in range(0,i):
if not (0 in lookup[j::i]):
is_true = 0
break
if not is_true:
break
if is_true:
print("NO")
else:
print("YES") | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | import traceback
import math
from collections import defaultdict
from functools import lru_cache
def main():
N = int(input())
nums = list(map(int, input().split()))
def check(j):
if not (N % j == 0 and N // j > 2):
return False
for i in range(j):
done = True
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
import java.math.*;
public class C {
public static void main (String[] args) throws IOException {
int n = xint();
int[] a = xints(n);
BitSet b = new BitSet();
b.set(2, n+1);
for (int i = 0; ; i++) {
if (i == n) {
System.out.println("YES");
... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static ... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | n = int(input())
a = list(map(int,input().split()))
fl = 0
for i in range(3,n + 1):
if n%i == 0:
for j in range(n//i):
f = 1
for k in range(j,n,n//i):
#print(k)
if a[k] == 0:
f = 0
break
if f:
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | n = int(input())
a = list(map(int,input().split()))
fl = 0
for i in range(3,n + 1):
if n%i == 0:
for j in range(n//i):
f = 1
for k in range(j,n,n//i):
#print(k)
if a[k] == 0:
f = 0
break
i... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
long long fix_mod(long long x, long long y) { return (y + x % y) % y; }
void fast() {
std::ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int vis[(int)1e5 + 10];
... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author duc
*/
pub... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | def find_divs(n):
divs=[]
for i in range(3,n+1):
if n%i==0:
divs.append(n//i)
return divs
n=int(input())
a=[int(i) for i in input().split()]
divs=find_divs(n)
for div in divs:
for shift in range(0, div):
if(all([i==1 for i in [a[j] for j in range(shift, n, div)]])):
print('YES')
quit()
print('NO') | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
int flag = 0;
int n;
cin >> n;
int num[100005];
int vis[100005];
for (int i = 0; i < n; ++i) {
cin >> num[i];
}
int cnt;
for (cnt = 2; cnt < n; cnt++) {
i... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
int main() {
int n, i, j, k;
int a[1000000];
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", &a[i]);
for (i = 1; i <= n / 3; i++) {
if (n % i == 0)
for (j = 0; j < i; j++) {
k = j;
while (a[k] && k < n) k = k + i;
if (k >= n) {
printf("... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public class RoundTableKnight implements Runnable {
private void solve() throws IOException {
int n = nextInt();
boolean [] b = new boolean[n];
for(int i=0;i<n;i++){
int x = nextInt();
if(x==1)
b[i]=true;
else
b[i]=false;
}
for(int i=3;i<=n;i++){
... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.IOException;
import java.util.InputMismatchException;
public class RoundTableKnights {
public static void main(String[] args) {
FasterScanner sc = new FasterScanner();
int N = sc.nextInt();
int[] A = sc.nextIntArray(N);
for (int p = 1; p <= N; p++) {
if (p > 2 && N % p == 0) {
int st... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class RoundTableKnights {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boole... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v, dev;
bool check(int number) {
int last = -1e9;
for (int i = 1; i <= n; i++) {
if (v[i] == 0 || i < last || (n - number) % number != 0) continue;
int j, q;
for (j = i, q = 0; q <= number; q++) {
int pos = j % n;
if (j < n) la... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
vector<int> d;
int A[100100];
int main() {
int n, i, j, k, p, temp;
scanf("%d", &n);
for (i = 0; i < n; i++) scanf("%d", &A[i]);
for (i = 1; i * i <= n; i++)
if (n % i == 0) {
d.push_back(i);
if (i > 2) d.push_back(n / i);
}
sort((d).begin(), (... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int N, A[MAXN];
bool flag[MAXN];
bool check(int n) {
if (n < 3) return false;
int d = N / n;
for (int i = 0; i < d; ++i) flag[i] = true;
for (int i = 1; i <= N; ++i)
if (!A[i]) flag[i % d] = false;
for (int i = 0; i < d; ++i)
if (f... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> a(n);
for (int i = 0; i < n; ++i) {
scanf("%d", &a[i]);
}
auto Check = [&, n](int x) {
for (int i = 0; i < x; ++i) {
bool ok = true;
int cnt = 0;
for (int j = i; j < n; j += x) {
... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public class roundtableknights {
public static void main (String [] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int numKnights = Integer.parseInt(in.readLine());
boolean [] good = new boolean[numKnights], pass ... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static boolean fortunate(int[] v) {
int n = v.length, iter = 0;
//Desde la posicion 0 hasta la posicion n/3
//puede comenzar el poligono tal que contenga
//minimo 3 vertices
for (int i = ... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
f... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | def polyPossible(k, knights):
n = len(knights)
group = n/k
this_group = True
for i in xrange(n/k):
if knights[i] == 0:
continue
this_group = True
for j in xrange(i, n, group):
if knights[j] == 0:
this_group = False
if this_group:
... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.*;
import java.io.*;
public class problem71C {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(System.in);
//Scanner in = new Scanner(new File("71C.in"));
int n = in.nextInt();
int[] knights = new int[n];
for (int i = 0; i < n; i++) knights[i] = i... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int m = n;
int a[n];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
vector<int> v;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
if (i > 2) v.push_back(i);
if ((n / i) != i && (n / i) > 2) v.push_back(... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | from sys import stdin
#x = [ '9', '1 0 0 1 1 1 0 0 1' ]
x = stdin.readlines()
lines = map( lambda x: x.strip(), x )
n = int( lines[0] )
a = map( int, lines[1].split( ' ' ) )
def go(n, a) :
for i in range( 1, n / 3 + 1 ) :
if n % i != 0 :
continue
for p in range( 0, i ) :
... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 | from math import sqrt
#def gcd(a,b):
# while b > 0: a,b = b, a%b
# return a
#def lcm(a, b):
# return a*b/gcd(a,b)
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,
67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137,
139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int arr[100000];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; ++i) cin >> arr[i];
for (int i = 1; n / i >= 3; ++i) {
if (n % i != 0) continue;
for (int j = 0; j < i; ++j) {
int Ok = 0;
for (int k = j; k < n; k += i) {
if (arr[k] =... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public class RoundTableKnights {
public static boolean constructPolygon(int[] a,int gap)
{
for (int i = 0; i < a.length; i++) {
//System.out.println("i: " + i);
boolean possible=true;
int indx=i;
while(true)
{
//System.out.println("indx: " + indx + " a[indx]... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.net.URL;
import java.util.*;
public class Template implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
void init() throws FileNotFoundException {
try {
in = new BufferedReader(new FileReader("input.... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool chmin(int64_t& a, const int64_t& b) { return b < a ? a = b, 1 : 0; }
bool chmax(int64_t& a, const int64_t& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31 - __builtin_clz(x); }
const i... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public class Main {
// static Scanner in;
static PrintWriter out;
static StreamTokenizer in; static int next() throws Exception {in.nextToken(); return (int) in.nval;}
public static void main(String[] args) throws Exception {
// in = new Scanner(System.in);
out = new PrintW... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
scanf("%d", &n);
vector<int> valid, in(n, 0);
for (int i = 0; i < n; i++) {
int mood;
scanf("%d", &mood);
if (mood) {
valid.push_back(i);
in[i] = true;
}
}
set<int> jps;
for (int i = 1; i * i <= n; i++) {
if ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.util.*;
public class Main {
public void doIt(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int [] num = new int[n];
for(int i=0; i < n; i++){
num[i] = sc.nextInt();
}
boolean flg = false;
//考えられる間隔分ループ
for(in... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[100004];
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d", a + i);
for (int i = 3; i <= n; i++)
if (n % i == 0) {
int d = n / i;
bool yes;
for (int r = 0; r < d; r++) {
yes = true;
for (int j = 0... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, a[100005];
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int sq = sqrt(n);
vector<int> div;
for (int i = 1; i <= sq; i++)
if (n % i == 0) {
if (n / i > 2) div.push_back(i);
if (i > 2) div.push_back(n / i);
}
bool ok... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | from math import *
n=input()
k=n
a=map(int, raw_input().split())
dis=[]
if n%4==0:
dis.append(4)
n/=4
for i in xrange(2, int(sqrt(n))+1):
while n%i==0:
n/=i
if i!=2:
dis.append(i)
if(n!=1):
dis.append(n)
n=k
flag=0
for i in xrange(len(dis)):
for j in xrange(n/dis[i]):
... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public final class round_table_knights
{
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static FastScanner sc=new FastScanner(br);
static PrintWriter out=new PrintWriter(System.out);
public static void main(String args[]) throws Exception... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;
p... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
public class C {
private static StreamTokenizer in;
private static PrintWriter out;
private static int nextInt() throws Exception {
in.nextToken();
return (int) in.n... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | from sys import stdin
def main():
n = int(input())
ar = list(map(int, stdin.readline().split()))
index = 1
divs = []
while index * index <= n:
if n % index == 0:
if index > 2:
divs.append(index)
if n // index != index and n // index > 2:
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | ###### ### ####### ####### ## # ##### ### #####
# # # # # # # # # # # # # ###
# # # # # # # # # # # # # ###
###### ######### # # # # # # ... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class RoundTableKnights implements Closeable {
private InputReader in = new InputReader(System.in);... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | x2=[]
x3=[]
x5=False
x=input("")
x1=raw_input("")
for i in range(0,len(x1),2):
x2.append(bool(int(x1[i])))
x=int(x)
x3.append(x)
for i in range(2,((x/2)+1)):
if x%i == 0 and (x/i) >= 3 :
x3.append(x/i)
x3.reverse()
c1=[True]*len(x3)
for i in range(len(x3)):
for j in range(... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Main {
private void solve() throws IOException {
int n = nextInt();
int[] knight = nextIntArray(n);
boolean res = false;
for (i... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, tmp, s[100005], pl[7], p = 0;
bool ok = false;
void chk(int ver) {
for (int i = 0; i < n / ver; i++) {
int cnt = 0;
for (int j = i; j < n; j += n / ver) cnt += s[j];
if (cnt == ver) {
ok = true;
return;
}
}
return;
}
int main() {
s... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool read(T &x) {
int c = getchar();
int sgn = 1;
while (~c && c<'0' | c> '9') {
if (c == '-') sgn = -1;
c = getchar();
}
for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
x *= sgn;
return ~c;
}
stru... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1e9 + 1;
constexpr long long LLINF = 1e18 + 1;
template <typename T>
T gcd(T a, T b) {
return b ? gcd(b, a % b) : a;
}
template <typename T>
T lcm(T a, T b) {
return a / gcd(a, b) * b;
}
const int nax = 1e5 + 10;
int ar[nax], n;
bool poss(int a) {
... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author jtimv
*/
import java.io.*;
public class Task {
public static void main(String[] args) {
new Task().main();
}
StreamTokenizer in = new StreamTokenizer(new BufferedReader(new Input... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | n=int(input())
b=list(map(int,input().split()))
p=int(n**0.5)+1
j=1
r=n
c=[]
while(j<p):
if n%j==0:
k=j
r=n//j
if k>=3:
c.append(k)
if r>=3 and r!=k:
c.append(r)
j+=1
c=sorted(c)
f=0
for r in c:
k = n // r - 1
dp = [1] * (k + 1)
j = 0
p = ... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
public class RoundTableKnights {
public static void main(String[] args) throws NumberFormatException,
IOException {
BufferedReader reader = new BufferedReader(new Inp... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int seive[N];
void pre() {
fill(seive + 2, seive + N, 1);
for (int i = 2; i < N; i++) {
if (seive[i]) {
for (int j = 2; j * i <= N; j++) {
seive[i * j] = 0;
}
}
}
}
int n, a[N];
void check(int i) {
if (n / i < 3) re... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
if (b == 0)
return a;
else
return gcd(b, a % b);
}
int bsearch(int l, int h, int a[], int key) {
int m = (l + h) / 2;
int ans = -1;
while (l <= h) {
if (a[m] == key) {
ans = m;
break;
} else if ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long M = 1e6 + 5;
const long long mod = 1e9 + 7;
long long a[N], cnt;
vector<long long> prime;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
long long n;
cin >> n;
long long m = n;
for (long long i = 0; i < n; ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int n;
int s[MAXN];
bool check(int k) {
for (int i = 0; i < k; i++) {
bool flag = true;
for (int j = i; j < n; j += k) {
if (!s[j]) {
flag = false;
break;
}
}
if (flag) return true;
}
return false;... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const int OO = (int)1e9;
int dx[8] = {0, 0, -1, 1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
long long n, z, cnt, ans;
vector<long long> divisors;
vector<int> a;
vector<long long> generate_divisors(long long n) {
vector<long long> v;
long long i;
for (i ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n;
bool mark[100000];
int good(int x) {
for (int i = 0; i < x; i++) {
for (int j = i; j <= n - x + i; j += x) {
if (mark[j] == 0) break;
if (j == n - x + i) return 1;
}
}
return 0;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >>... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.io.*;
import java.util.*;
public class Task7c {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = s.nextInt();
}
for (int i = 3; i <... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 |
import java.awt.Point;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.ObjectInputStream.GetField;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.ut... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long int T = 1;
while (T--) {
long long int n, i, t, j, k;
cin >> n;
long long int N = n;
bool mood[n + 5];
bool chh = true;
for (i = 0; i < n; i++) {
cin >> mood[i];... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.*;
import java.io.*;
import java.math.*;
public class C
{
public static void process(int test_number)throws IOException
{
int n = ni(), mood[] = new int[n+1];
for(int i = 1; i <= n; i++)
mood[i] = ni();
ArrayList<Integer> div = new ArrayList<>();
... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
bool chmin(int64_t& a, const int64_t& b) { return b < a ? a = b, 1 : 0; }
bool chmax(int64_t& a, const int64_t& b) { return a < b ? a = b, 1 : 0; }
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31 - __builtin_clz(x); }
const i... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
for (int k = 1; k <= n / 3; k++) {
if (n % k == 0) {
for (int p = 0; p < k; p++) {
int sum = 0;
for (int v = p; v < n; v += k) {
if (a[v] == 1) sum... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
const long double pi = 3.14159265358979323846;
long long MOD = 998244353;
const char nl = '\n';
const long long inf = 1e15;
long long power(long long x, long long y) {
long long z = 1;
while (y > 0) {
if (y % 2) z = z * x;
x = x * x;
y /= 2;
}
return z;
... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int a[(int)1e5 + 1];
int main() {
int n;
scanf("%d", &n);
bool ok = true;
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
ok = min((a[i] == 1), ok);
}
if (ok) return printf("YES"), 0;
vector<int> div;
for (int i = 2; i * i <= n; i++) {
if (!(n ... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int n, a[100020], z;
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i <= n / 3; i++)
if (n % i == 0)
for (int j = 0; j < i; j++) {
z = 1;
for (int k = j; k < n; k += i) z &= a[k];
if (z) {
co... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | def put(): return map(int, input().split())
n = int(input())
l = list(put())
for i in range(1,n):
if n%i==0 and n//i >=3:
for j in range(i):
a = 1
for k in range(j, n, i):
a&= l[k]
if a==1:
#print(j,i)
print('YES')
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | import re
n = int(raw_input())
a = map(int, raw_input().split())
d = []
for i in xrange(1, n):
if i * i > n: break
if n % i == 0:
d.append(i)
if (i != n / i):
d.append(n / i)
flag = True
for i in xrange(len(d)):
if n / d[i] >=3:
for k in xrange(0, d[i]):
flag... | PYTHON |
71_C. Round Table Knights | 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 ... | 2 | 9 | from math import sqrt
def eratosthenes(n):
A = [True]*(n+1)
for i in range(2, int(sqrt(n)) + 1):
if A[i]:
for j in range(i**2, n+1, i):
A[j] = False
return [i for i in range(2, len(A)) if A[i]]
def knights(n, Table):
P = eratosthenes(n)
P[0] = 4
for k in P:
... | PYTHON3 |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
int k;
vector<int> v;
cin >> n;
int nn = n;
while (nn--) {
cin >> k;
v.push_back(k);
}
for (int x = 1; x * 3 <= n; ++x) {
if (n % x != 0) {
continue;
}
for (int y = 0; y < x; ++y) {
int z;
for (z = y;... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | import java.util.ArrayList;
import java.util.Scanner;
public class Codeforces71C {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boolean valid = true;
ArrayList<Boolean> list = new ArrayList<Boolean>();
... | JAVA |
71_C. Round Table Knights | 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 ... | 2 | 9 | #include <bits/stdc++.h>
long long MM = 1000000007;
using namespace std;
long long gcd(long long a, long long b) {
if (a == 0 || b == 0) return abs(a - b);
long long res = a % b;
while (res) {
a = b;
b = res;
res = a % b;
}
return b;
}
long long lcm(long long a, long long b) { return a * b / gcd(a... | CPP |
71_C. Round Table Knights | 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 ... | 2 | 9 | N=int(input())
A=input().split()
if(A.count('1')<=2):
print("NO")
else:
done=False
diff=0
while(not done):
diff+=1
if(N//diff<=2):
break
if(N%(diff)!=0):
continue
for start in range(diff):
done=True
for j in range(start,N,... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.