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 | import java.util.*;
public class RoundTable{
private static boolean[] primo = new boolean[100010];
private static void cribaErasthotenes(){
for(long i = 2; i < 100010; i++){
if(!primo[(int)i])
for(long j = i * i; j < 100010; j += i)
primo[(int)j] = true... | 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.*;
import java.io.*;
//code forces 71C round table knights
public class Main{
public static void main(String [] args) throws Exception{
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(in.readLine());
String [] g = in.readLine().split(" ");
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
/**
* Created by Tejas on 21-07-2018.
*/
public class Main {
static int a[];
static ArrayList<Integer>div=new ArrayList<>();
public static void main(Stri... | 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 RoundTableKnights {
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt(),temp=n;
ArrayList<Integer>primes=new ArrayList<Integer>();
for(int i=3;i<=temp;i++){
if(temp%i==0)
primes.add(i);
while(temp%i==0)
temp/=i;
}
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 | 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
*/
public cl... | 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 | //package CF;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;
public class B {
static int [] a;
... | 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.*;
import java.math.BigInteger;
import java.util.*;
import static java.lang.Math.*;
public class Solution71C {
final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null;
BufferedReader in;
PrintWriter out;
StringTokenizer tok =... | 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 arr[100001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int flag = 0;
int cnt;
for (int i = 0; i < n; i++) {
while (arr[i] != 1) i++;
for (int d = 1; d <= n / 2; d++) {
if (n % d != 0) continue;
cnt... | 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>
const int md = 1e9 + 7;
const long long hs = 199;
using namespace std;
int n, a[100000];
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 3; i <= n; i++) {
if (n % i == 0) {
for (int j = 0; j < 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 | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author dipankar12
*/
import java.io.*;
import java.util.*;
public class r71c {
public static void main(String args[])
... | 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.util.*;
import java.math.*;
public class C {
private void solve() throws IOException {
int n = Integer.parseInt(stdin.readLine());
StringTokenizer o = new StringTokenizer(stdin.readLine());
boolean[] b = new boolean[n];
for (int i = 0; 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 | #include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int v[NMAX];
int first;
bool check(int n, int x) {
int curr = first;
int ct = 0;
for (int i = 1; i <= 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 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int M = 1e9 + 7;
const int MOD = 998244353;
const double PI = 3.141592653589793238460;
long long int power(long long int a, long long int b) {
long long int res = 1;
if (a == 0) return 0;
if (a == 1) return 1;
for (; b > 0; b >>= 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 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
long long T, n, m, k, x, y, z, l, r, ans, spf[N], a[N], mod = 1e9 + 7;
int f() {
for (int i = 1; i <= n / 3; i++) {
if (n % i == 0) {
for (int j = 1; j <= i; j++) {
int s = 1;
for (int k = j; k <= n; k += i) s &= a[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.util.*;
import java.io.*;
import java.math.*;
public class JavaApplication48 {
static void printDivisors(int n) {
// Note that this loop runs till square root
for (int i = 1; i <= Math.sqrt(n); i++) {
if (n % i == 0) {
// If divisors are equal, print only o... | 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 n;
long long a[100002];
bool chk(long long p, long long d) {
long long rq = n / d;
if (rq <= 2 || !a[p]) return 0;
for (long long i = p + d; i != p; i = (i + d) % n) {
if (a[i] != 1) return 0;
}
return 1;
}
int main() {
ios::sync_with_stdio(0), 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.util.*;
import java.io.*;
public class Main{
BufferedReader in;
StringTokenizer str = null;
private int nextInt() throws Exception{
if (str == null || !str.hasMoreElements())
str = new StringTokenizer(in.readLine());
return Integer.parseInt(str.nextToken());
}
int n, st;
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 ar[100010];
int gcd(int a, int b) {
if (a > b) return gcd(b, a);
if (a == 0) return b;
return gcd(b % a, a);
}
int n;
bool isit(int k) {
int len = k;
int len2 = n / k;
for (int t = 0; t < len; t++) {
int p = t;
int cnt = 0;
bool ok = true;
wh... | 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 sys
from array import array # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
def get_primes(n: int):
from itertools import chain
from array import array
primes = [3, 4]
is_prime = (array('b', (0, 0, 1, 1, 0, 1, 0)) +
array('b', (1, 0, 0, 0, 1, ... | 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 | from sys import stdin
from sys import exit
from math import sqrt
#parser
def parser():
return map(int, stdin.readline().split())
#Comprobar si el número de entrada es primo o es 4
def IsPrime(t):
if t<3:
return False
if t==4:
return True
for i in range(2,int(sqrt(t))+1):
if t%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;
const int maxn = 100000 + 5;
bool m[maxn];
int a[maxn];
int main() {
int n, sum = 0;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
}
if (n == sum) {
cout << "YES" << endl;
return 0;
}
bool flag = false;
for (int t = 3; 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 | #!/usr/bin/python
import sys
import math
if __name__=="__main__":
data = sys.stdin.readlines()
n = int(data[0])
li = [int(v) for v in data[1].split(' ')]
for v in li:
if v == 0:
break
else:
print "YES"
exit()
li += li
steps = []
for i in range(n-1... | 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 | n = int(input())
sr = [int(i) for i in input().split()]
v = 0
for sh in range(1, int(len(sr) / 3) + 1):
if len(sr) % sh == 0:
for j in range(1, sh + 1):
for i in range(j, len(sr), sh):
if sr[i] == 0:
break
else:
v = 1
if v == 1:... | 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 arr[100001];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
int flag = 0;
int cnt;
for (int i = 0; i <= n / 3; i++) {
while (arr[i] != 1) i++;
for (int d = 1; d <= n / 3; d++) {
if (n % d != 0) continue;
... | 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;
const int N = 200001;
bool bs[200001];
vector<int> p;
vector<int> sol;
vector<int> g;
bool vis[200001];
void sieve() {
memset(bs, true, sizeof bs);
bs[0] = bs[1] = false;
for (int i = 2; i * i < N; i++)
if (bs[i])
for (int j = i * i; j < N; j += i) bs... | 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 math
n=input()
arr=map(int,raw_input().split())
a=0
s=0
for i in arr:
if i==0:
s+=1
else:
a=max(a,s)
s=0
a=max(a,s)
p=3
new=[]
ver=[]
for i in range(1,int(math.sqrt(n))+1):
if n%i==0:
new.append(i)
new.append(n/i)
for h in range(len(new)):
ans=new... | 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;
const int M = 1e9 + 7;
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t, n, i, j, k, ans;
cin >> n;
vector<int> v(n);
for (int i = 0; i < n; i++) cin >> v[i];
vector<int> fact;
for (i = 1; i * i < n; i++) {
if (n % i == 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 | //package round65;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class C {
static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static PrintWri... | 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())
def rp_found_begin_pos(side_length,number_of_sides,begin_pos):
pos=begin_pos
while number_of_sides!=0:
if not knights_mood[pos]:
return False
pos+=si... | 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 | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
/**
*
* @author dody
*/
public class ProbC {
/**
* @param args the command line arguments
*/
public static void ma... | 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 foo(listSize,list):
for subSize in range(1,listSize+1):
if listSize%subSize==0:
parts=listSize/subSize
if parts ==1:
_sum = sum(list)
if (listSize == _sum):
return "YES"
if parts >2:
for i in range(s... | 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.*;
public class tr {
public static void main(String[] args) throws IOException {
Scanner sc=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int n=sc.nextInt();
int []a=new int[n];
int ones=0;
for(int i=0;i<n;i++) {
a[... | 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, os, math
def er(k):
a = [True for i in range(k + 1)]
a[0] = a[1] = False
global p
p = [2]
m = 2
while m < k:
for i in range(k // m):
a[(i + 1) * m] = False
a[m] = True
i = m + 1
while (not a[i]) & (i < k): i = i + 1
if i < k:
... | 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.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
/**
* Created by IntelliJ IDEA.
* User: piyushd
* Date: 3/18/11
* Time: 9:28 PM
* To change this template use File | Settings | File Templates.
*/
public class TaskC {
void run(){
int n = nextInt();
int[] a = new ... | 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
def main():
lines = [i.rstrip() for i in sys.stdin.readlines()]
nums = [int(i) for i in lines[1].split(" ")]
size = len(nums)
for i in range(1, (size + 1) / 2):
if (size % i != 0):
continue
for j in range(i):
for k in range(size / 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.*;
import java.lang.*;
public class Rextester{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringToken... | 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>
int n, a[100005];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
for (int i = 1; i <= n / 3; i++) {
if (n % i == 0) {
for (int j = 1; j <= i; j++) {
int flag = 1;
for (int k = j; k <= n; k += i)
if (!a[k]) flag = 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 | /*
* Hello! You are trying to hack my solution, are you? =)
* Don't be afraid of the size, it's just a dump of useful methods like gcd, or n-th Fib number.
* And I'm just too lazy to create a new .java for every task.
* And if you were successful to hack my solution, please, send me this test as a message or to Abr... | 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 dp[100010][320];
int a[100010], p[100];
int n, s = 0;
int go(int i, int j, int b, int c) {
if (i >= b + n) return c;
int& ans = dp[i][j];
if (ans != -1) return ans;
ans &= go(i + p[j], j, b, c & a[i]);
return ans;
}
int main() {
ios_base::sync_with_stdio(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 | from sys import stdin
from sys import exit
from math import sqrt
#parser
def parser():
return map(int, stdin.readline().split())
def IsPrime(t):
if t<3:
return False
if t==4:
return True
for i in range(2,int(sqrt(t))+1):
if t%i==0:
return False
return True
def ... | 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.*;
public class Main {
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){br = new BufferedReader(new InputStreamReader(System.in));}
String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTok... | 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;
import java.util.Arrays;
public class Main {
private static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
private static PrintWriter out =... | 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.util.* ;
public class HelloWorld {
static int a [] ;
public static void main (String args [] ) throws IOException ,InterruptedException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt() ;
a... | 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 double PI = 3.14159265358979;
const double PI2 = 6.28318530717958;
const double PId2 = 1.570796326794895;
inline long long pw(long long n, int p) {
long long ans = 1;
for (int i = 0; i < p; i++) ans *= n;
return ans;
}
inline vector<int> ReadVI(int count) {
ve... | 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 main():
n=int(input())
a=input().split(" ")
a=[int(i) for i in a]
for k in range(1,int(n/3)+1):
if(int(n%k)==0):
for p in range(k):
sum1=0
for v in range(p,n,k):
if(a[v]==1):
sum1+=1
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 main() {
int n;
cin >> n;
vector<int> mood(n, -1);
for (int i = 0; i < n; i++) {
cin >> mood[i];
}
for (int i = 0; i < n; i++) {
if (mood[i] == 1) {
for (int j = n; j >= 3; j--) {
if (n % j != 0) continue;
bool found = true;
... | 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.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class RoundTableKnights implements Runnable {
private void solve() throws IOException {
int n = nextInt();
int[] t = new int[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 | n=int(input())
a=list(map(int,input().split()))
l=[] # i vertices
m=n
for i in range(3,n+1):
if m%i==0:
l.append(i)
while m%i==0:
m//=i
for p in l:
q=n//p
cnt=[0]*n
for i in range(n):
if a[i]==1:
cnt[i]=1
for s in range(q):
for j in range(s,n+q,q):
cnt[(j+q)%n]+=cnt[j%n]
fo... | 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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.StringTokenizer;
public class F {
public static void main(String[] args) throws IOException {
... | 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 getPrimes(n):
primes = []
if n % 4 == 0:
primes.append(4)
while n % 2 == 0:
n //= 2
div = 3
while n > 1:
if n % div == 0:
primes.append(div)
while n % div == 0:
n //= div
div += 1
return primes
def islucky(n, knights, pr... | 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 f(n):
n += 1
t = [1] * n
for i in range(3, int(n ** 0.5) + 1, 2):
u, v = i * i, 2 * i
if t[i]: t[u :: v] = [0] * ((n - u - 1) // v + 1)
return [4] + [i for i in range(3, n, 2) if t[i]]
n, t = int(input()), list(map(int, input().split()))
q = [n // i for i in f(n) if n % 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;
long long int mod = 1e9 + 7;
const double error = 1e-8;
const double PI = acos(-1);
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
inline long long int MOD(long long int x, long long int m = mod) {
long long int y = x % m;
return (y >= 0) ? y : 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.io.*;
import java.math.*;
import java.util.*;
/**
* @author Egor Kulikov (egor@egork.net)
* @author Alexey Safronov (safronov.aa@gmail.com)
*/
public class Round65 {
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
private InputReader in;
private PrintWriter out;
... | 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 mood[100005];
int n;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> mood[i];
}
for (int i = 1; i < (n + 1) / 2; i++) {
if (!(n % i) and n / i != 2) {
for (int j = 0; j < i; j++) {
bool check = true;
for (int k = 0; (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 TaskC {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = sc.nextInt();
ArrayList<Integer> div = new ArrayList<>();
int... | 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.Scanner;
/**
* Author: dened
* Date: 26.03.11
*/
public class C {
public static void main(String[] args) throws IOException {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
boolean[] a = 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 | m = n = int(raw_input())
a = map(int,raw_input().split())
t=0
for _ in xrange(3, n+1):
if (n % _ == 0):
s = n / _
else:
continue
for st in xrange(s):
i = st
while (i < n and a[i]):
i += s
if (i >= n):
t=1
break
if t==0: print 'NO'
e... | 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 Main
{
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = 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 | #include <bits/stdc++.h>
using namespace std;
const int N = 100005, oo = 0x3f3f3f3f;
int n, v[N], vis[N];
vector<int> primes;
void genprimes() {
memset(vis, 0, sizeof vis);
for (long long i = 3; i < N; i += 2) {
if (!vis[i]) {
primes.push_back(i);
for (long long j = i * i; j < N; j += i) {
v... | 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 math
n = int(input())
l = list(map(int,input().split()))
factors = []
for i in range(1,int((n+1)/2)):
if n%i == 0:
factors.append(i)
f = 1
for d in factors:
for i in range(d):
k = 0
while True:
if k >= n:
f = 0
break
elif l[i+k] == 1:
k += d
continue
elif l[i+k] == 0:
bre... | 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 | p=[0]*10000
for i in range(2,10000):
if not p[i]:
for j in range(i+i,10000,i):
p[j]=1
p[4]=0
n=input()
a=map(int,raw_input().split())
for i,e in enumerate(p[3:],3):
if e: continue
if i > n: break
if n%i: continue
for j in range(n/i):
if all(a[j::n/i]):
print ... | 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.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class RoundTableKnights
{
public static void main(String[] args)
{
boolean[] sieve = new boolean[100001];
for(int i = 2; 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static boolean fortunate(int[] v) {
int n = v.length, iter = 0;
for (int i = 0; i < n / 3; i++)
if (v[i] == 1)
for (int j = 1; j <= n / 3; j++) {
iter = i;
do
iter = (ite... | 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 maxn = 100000 + 10;
const long long MOD = 1000000000 + 9;
bool a[maxn * 2];
int n;
int at[maxn * 2][300 + 10];
vector<int> d;
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i + n] = a[i];
}
for (int i = 1; i * i <= 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>
using namespace std;
int arr[100001];
int main() {
int n, i, be, len, num, k, t;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
for (len = n / 3; len > 0; len--) {
if (n % len != 0) continue;
t = n / len;
for (i = 0; i < n; i++) {
num = 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 | #include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cer... | 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.InputStreamReader;
public class C {
public static boolean check(boolean[] A, int i) {
int n = A.length;
int dif = n / i;
boolean[] visited = new boolean[n];
for (int j = 0; j < n; j++) {
if (!A[j]... | 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.*;
import javafx.util.Pair;
public class practice {
public static void main(String[] args) {
Scanner scn=new Scanner(System.in);
int n=scn.nextInt();
int[] arr=new int[n+1];
for(int i=1;i<=n;i++){
arr[i]=scn.nextInt();
}
int flag=1;
for(int i=1;i<=n/3;i++){
if(n%i==0){
f... | 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.util.*;
import java.math.*;
public class Main{
static class Solver{
Vector<Integer> div(int x){
Vector<Integer> d = new Vector<Integer>();
for(int i = 1; i * i <= x; ++i){
if(x % i == 0){
d.add(i);
if(i != x / i){
d.add(x / 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;
inline void getarrint(vector<int>& a, int n, istream& in) {
for (int i = 0; i <= n - 1; i++) in >> a[i];
}
class Solution {
public:
void solve(std::istream& in, std::ostream& out) {
int n;
in >> n;
vector<int> mood(n);
getarrint(mood, n, in);
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 |
#some convinient function
def make_primelist(size):
global prime
from math import sqrt
_prime=[1 for i in xrange(size+1)]
_prime[0]=0
_prime[1]=0
for i in xrange(size):
if i*i>size:
break
if _prime[i]==0:
continue
for k in xrange(2*i,size+1,i):
_prime[k]=0
prime=_prime
cho... | 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.awt.Point;
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class PracticeProblem
{
/*
* This FastReader code is taken from GeeksForGeeks.com
* https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/
*
* The article was written by Rishab... | 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
class pythonin:
_data = []
_cur = 0
def __init__(self):
while True:
try: sm = raw_input().split(" ")
except EOFError: break
for x in sm :
if x != "" and x != "\t" :
self._data.append(x)
def eof(... | 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;
void require(bool cond, const string& message = "Runtime error") {
if (!cond) {
cerr << message << endl;
assert(false);
}
}
void readData() {}
bool good(const vector<int>& a, int k) {
int n = a.size();
if (n / k < 3) return false;
for (int j = 0; j < int(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 | #include <bits/stdc++.h>
using namespace std;
int n;
bool f, a[(int)1e6 + 9];
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i < (n == 3 ? 2 : (n >> 1)); i++) {
if (n % i == 0) {
for (int j = 0; j < i; j++) {
if (!a[j]) continue;
int k = j + i;
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 | import java.io.*;
import java.util.*;
public class A implements Runnable{
public static void main (String[] args) {new Thread(null, new A(), "_cf", 1 << 28).start();}
public void run() {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
System.err.println("Go!");
int max = ... | 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 MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double eps = 1e-7;
int n;
int a[MAX];
vector<int> v;
void GenerateDivisors(int n) {
int i;
for (i = 1; i * i < n; ++i) {
if (n % i == 0) {
v.push_b... | 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.*;
public class CF_71_C_ROUND_TABLE_KNIGHTS {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boolean[] a = new boolean[n];
for (int i = 0; i < n; i++) {
a[i] = sc.nextInt() == 1;
}
ArrayList<Int... | 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, a[100005], b[100005];
int main() {
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
int s = 0;
for (int i = 0; i < n; i++) s += a[i];
if (s == n) {
cout << "YES";
return 0;
}
for (int j = 2; j * j <= n; j++)
if (n % j == 0) {
int 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 | import java.util.*;
import java.io.*;
public class Main {
static BufferedReader br;
static PrintWriter pw;
static int inf = (int) 1e9;
static int mod = (int) 1e9 + 7;
static long[][][] memo;
static int[] a, rArr, gArr, bArr;
public static void main(String args[]) throws Exception {
br = new BufferedReader(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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
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 | #include <bits/stdc++.h>
using namespace std;
int n;
int arr[100005];
bool go(int i) {
int t = 1;
for (int j = 0; j < i; j++) {
t = 1;
for (int k = j; k < n; k += i) {
t &= arr[k];
if (!t) break;
}
if (t) {
return true;
}
}
return false;
}
int main() {
int i, j, k;
scan... | 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 a {
public static void main(String[] argrs) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
ArrayList<Integer> factors = new ArrayList<Integer>();
for(int i=1; i<=n/3; i++)
if(n%i==0)
factors.add(i);
boolean[] v = new boolean[n];
for(int i=0; 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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class C71 {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
boolean[] k =... | 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 math
n = int(input())
ar = list(map(int,input().split()))
def check(d):
if n//d<=2:
return 0
for i in range(d):
for j in range(i,n,d):
if not ar[j]:
break
else:
return 1
return 0
root = int(math.sqrt(n))
for i in range(1,root+1):
if n%i==0 and (check(i) or check(n//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 java.io.*;
import java.util.*;
public class icpc
{
public static void main(String[] args) throws IOException
{
Reader in = new Reader();
//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int n = in.nextInt();
int[] A = new int[n];
for (int... | 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.util.*;
public class j
{
public static void main(String aa[])throws IOException
{
BufferedReader b=new BufferedReader(new InputStreamReader(System.in));
int flag=0,p=0,i=0,n=0,j=0,m=0;
String s;
m=Integer.parseInt(b.readLine());
int d[]=new int[m];
s=b.readLine();
StringTokenizer z=new Str... | 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.util.*;
public class C {
private static int numbers[], n;
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
InputStream inputStream = System.in;
OutputStream outputStre... | 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;
set<int> primeFactors(int n) {
set<int> s;
if (n % 4 == 0) {
s.insert(4);
n /= 4;
}
while (n % 2 == 0) n /= 2;
for (int i = 3; i <= sqrt(n); i = i + 2)
while (n % i == 0) {
s.insert(i);
n = n / i;
}
if (n > 2) s.insert(n);
return 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;
long long int power(long long int a, long long int b) {
if (b == 0) return 1;
long long int p = power(a, b / 2);
if (b % 2 == 0)
return p * p;
else
return a * p * p;
}
long int gcd(long int a, long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
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 b[1000005], a[1000006], n;
bool check(int k) {
int i, j, x;
for (i = 0; i < n / k; i++) {
for (j = 1, x = i; j <= k; j++, x += n / k)
if (a[x] == 0) break;
if (j > k) return 1;
}
return 0;
}
int main() {
int i, j;
scanf("%d", &n);
for (i = 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;
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, x, y;
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.util.*;
public class test {
static int moods[];
static int n;
static boolean flag=false;
public static int solver(int a){
if(a<3)
return 0;
int cnt=0;
for(int i=0;i<n/a;i++){
for(int j=i;j<n;j+=n/a){
if(moods[j]==1)
cnt++;
}
if(cnt==a){
flag=true;
//System.out.printl... | 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_base::sync_with_stdio(0), cin.tie(0);
int n;
cin >> n;
vector<int> a(n);
for (auto& i : a) cin >> i;
for (int x = 1; x * x <= n; x++) {
if (n % x) continue;
for (auto d : {x, n / x})
for (int from = 0; from < d; from++) {
b... | 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 (cin >> n) {
for (int i = 0; i < n; i++) cin >> a[i];
int x = n;
bool res = false;
for (int i = 1; i <= n / 3; i++) {
if (n % i) continue;
for (int j = 0; j < i; j++) {
bool find = true;
... | 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;
void solve(){};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
bool a[n];
int cnt = 0;
vector<int> ps;
for (int i = 0; i < n; ++i) {
int b;
cin >> b;
a[i] = b;
if (b) ++cnt;
}
int num = n;
if (num % 4 == 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 | /**
*
* @author xerxes
*/
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class C {
StringTokenizer st ;
BufferedReader bf;
int n;
int[] ar;
public static void main(String[] args){
C ob = new C();
ob.run();
... | 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.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashSet;
import java.util.StringTokenizer;
imp... | 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[100002];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int p;
for (int i = 1; i <= n / 3; i++) {
if (n % i == 0) {
for (int j = 1; j <= i; j++) {
if (a[j]) {
p = 1;
for (int k = j; 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 | #include <bits/stdc++.h>
int a[100001];
int main() {
int i, j = 1, k, l, m = 0, n;
scanf("%d", &n);
for (i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
for (i = 1; n / i >= 3; i++) {
if (n % i != 0) continue;
for (k = 1; k <= i; k++) {
for (j = k; j <= n; j += i) {
if (a[j] == 0) break;... | CPP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.