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 |
|---|---|---|---|---|---|
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | import sys
import math
#to read string
get_string = lambda: sys.stdin.readline().strip()
#to read list of integers
get_int_list = lambda: list( map(int,sys.stdin.readline().strip().split()) )
#to read integers
get_int = lambda: int(sys.stdin.readline())
sys.setrecursionlimit(10**5)
#--------------------------------Whi... | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(input())
arr = [[0, ''] for i in range(n)]
a = input()
b = [int(i) for i in input().split()]
for i in range(len(a)):
arr[i][1] = a[i]
for i in range(len(b)):
arr[i][0] = b[i]
arr = sorted(arr)
res = 2e9
for i in range(n-1):
if arr[i][1] == 'R' and arr[i+1][1] == 'L':
res = min(res, (arr[i+1]... | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(input())
s = str(input())
index = list(map(int , input().split()))
i =0
ans = 9999999999999
while i<len(s)-1:
if s[i]=='R' and s[i+1]=='L':
ans = min( ans , (( index[i+1] - index[i] )//2 ) )
i = i+1
if ans==9999999999999:
print(-1)
else:
print(ans) | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | /*
* Code Author: Akshay Miterani
* DA-IICT
*/
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class A {
static double eps=(double)1e-15;
static long mod=(int)1e9+7;
public static void main(String args[]){
InputReader in = new InputReader(System.in);
OutputStream outpu... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(input())
dir = input()
a = list(map(int, input().split()))
ans = 10 ** 20
for i in range(n - 1):
if dir[i] == 'R' and dir[i + 1] == 'L':
ans = min(ans, (a[i + 1] - a[i]) // 2)
if ans == 10 ** 20:
print(-1)
else:
print(ans) | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
long long maxint = 1e9 + 7;
long long n;
string st;
void openFile() { freopen("inp.txt", "r", stdin); }
void solve() {
cin >> n;
cin.ignore(1);
cin >> st;
long long px = -1;
long long res = maxint, x;
for (int i = 0; i < n; i++) {
cin >> x;
if (st[i] == ... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(raw_input().strip())
dir = list(raw_input())
pos = map(int,raw_input().split())
minDis = 1000000005
for i in range(1,n):
if dir[i] == 'L' and dir[i-1] == 'R':
minDis = min(minDis, pos[i] - pos[i-1])
if minDis == 1000000005:
print '-1'
else:
print minDis / 2 | PYTHON |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 |
import java.util.Scanner;
public class Ps {
public static void main(String[] args){
Scanner input =new Scanner(System.in);
int n=input.nextInt();
String str=input.next();
long moment=(long) 1e9;
int arr[]=new int[n];
for (int i = 0; i < n; i++) {
arr[i]=... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class A {
public static void main(String[] args) {
InputReader in = new InputReader(Syst... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int n;
struct node {
int d, l;
} a[200005];
int ans = 1000000000;
char ch[200005];
int main() {
scanf("%d", &n);
scanf("%s", ch + 1);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i].l);
if (ch[i] == 'L')
a[i].d = -1;
else
a[i].d = 1;
}
f... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | def main():
n = int(input())
directions = input()
x = [int(y) for y in input().split()]
last_r = -1
res = -1
for i in range(0, n):
if directions[i] == 'L':
if last_r != -1:
res = (res >= 0 and min(res, (x[i] - x[last_r]) // 2)) or (x[i] - x[last_r]) // 2
... | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(input())
c = list(input())
p = list(map(int,input().split()))
f = ["R","L"]
ans=[]
for i in range(n-1):
if [c[i],c[i+1]] == f:
ans.append(p[i+1]-p[i])
if len(ans)==0:
print(-1)
else:
print(min(ans)//2)
| PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n=int(input())
s=input()
A = input().split()
for i in range(len(A)):
A[i] = int(A[i])
min1=10000000000
for i in range (1,n):
if A[i]-A[i-1]<min1 and s[i]=='L' and s[i-1]=='R':
min1=A[i]-A[i-1]
if min1==10000000000:
print(-1)
else:
print(min1//2)
| PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, x, t = -1;
char c;
cin >> n;
vector<char> d;
vector<int> coord;
for (int i = 0; i < n; i++) {
cin >> c;
d.push_back(c);
}
for (int i = 0; i < n; i++) {
cin >> x;
coord.push_back(x);
}
for (int i = 0; i < n - 1; i++) {
... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n = int(input())
moves = input()
positions = list(map(int, input().split(' ')))
ans = 10 ** 9
for i in range(n-1):
if moves[i] == 'R' and moves[i+1] == 'L':
ans = min(ans, (positions[i+1] - positions[i]) // 2)
if ans == 10 ** 9:
print(-1)
else:
print(ans)
| PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int a;
cin >> a;
long long ar[a + 2];
string s;
cin >> s;
for (int i = 0; i < a; i++) {
cin >> ar[i];
}
long long f = 1, m = INT_MAX;
for (int i = 0; i < a - 1; i++) {
if (s[i] == 'R' && s[i + 1] == 'L')... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
if (a == 0) return b;
return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
T ans = 1;
while (b > 0) {
if (b % 2 == 1) ans = ((ans % m) * (a % m)) % m;
b /= 2;
a = ((a % m) * (a % m)) % m;
... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | n=int(input())
napr=input()
stroka=input()
coord=[]
k=''
answer=10**10
for i in range(0,len(stroka)):
if i==len(stroka)-1:
coord.append(int(k+stroka[i]))
elif stroka[i]==' ':
coord.append(int(k))
k=''
else:
k+=stroka[i]
for i in range(1,n):
if (napr[i]=='L')and(napr[i-1]=... | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
string s;
int a, b = 0;
cin >> n;
cin >> s;
int ans = 2000000000;
for (int i = 0; i < n; i++) {
a = b;
cin >> b;
if (i) {
if (s[i] == 'L' && s[i - 1] == 'R') ans = min(ans, (b - a) / 2);
}
}
if (ans == 2000000000) ... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
int d[1234678], a[1234678], ans;
int main() {
int n, cnt = 0;
char c;
scanf("%d\n", &n);
for (int i = 1; i <= n; i++) {
scanf("%c", &c);
d[i] = (c == 'R');
}
for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
ans = 1047483647;
for (int i = 2; i <= n; i... | CPP |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | import java.io.BufferedReader;
import java.io.IOException;
public class forces_363A {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
java.io.BufferedReader dd = new BufferedReader (new java.io.InputStreamReader(System.in));
int n = Integer.parseInt(dd.readLine()... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | //package credit;
import javax.swing.text.MutableAttributeSet;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.beans.IntrospectionException;
import java.io.*;
import java.net.Inet4Address;
import java.sql.SQLIntegrityConstraintViolationException;
import java.time.temporal.ChronoField;
import java.... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | x=int(input())
n=input()
m=list(map(int,input().split()))[:x]
ar=[]
s=0
mini=1000000000000000000
for i in n:
ar.append(i)
for j in range(0,x-1):
if(ar[j]=="R" and ar[j+1]=="L"):
s=(m[j+1]-m[j])//2
mini=min(mini,s)
if(s):
print(mini)
else:
print("-1")
| PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | 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.io.InputStream;
import java.util.ArrayList;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author E... | JAVA |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | input()
ds = str.strip(input())
xs = map(int, str.split(input()))
best = None
last_right = None
for d, x in zip(ds, xs):
if d == "R":
last_right = x
elif last_right is not None:
t = (x - last_right) // 2
best = min(best or t, t)
print(best or -1)
| PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | def solve(pos, dir, n):
ans = 987654321
for idx in xrange(0, n - 1):
if dir[idx] == 'R' and dir[idx+1] == 'L':
ans = min(ans, (pos[idx+1] - pos[idx])/2)
if ans == 987654321:
return -1
return ans
# print solve([2,4,6,10], 'RLRL', 4)
# print solve([40,50,60], 'LLR', 3)
n = input()
dir = raw_input().strip... | PYTHON |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | import sys
if __name__ == '__main__':
n = list(map(int, sys.stdin.readline().split(" ")))[0]
a = list(sys.stdin.readline())
x = list(map(int, sys.stdin.readline().split(" ")))
m = 100000000000
for i in range(n-1):
if a[i]=='R' and a[i+1]=='L':
m = min(m,(x[i+1]-x[i])/2)
if m... | PYTHON3 |
699_A. Launch of Collider | There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the dista... | 2 | 7 | #include <bits/stdc++.h>
using namespace std;
char str[1010000];
int b[1010000];
int a[1010000];
int bb[1010000];
int main() {
int n;
int flag = 1;
scanf("%d", &n);
scanf("%s", str);
for (int i = 1; i <= n; i++) {
scanf("%d", &b[i]);
}
int coutt1 = 0;
for (int i = 0; i <= n - 1; i++) {
if (str[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.Scanner;
public class P071C {
public static void main(String[] args) {
Scanner inScanner = new Scanner(System.in);
int n = inScanner.nextInt();
int[] moods = new int[n];
for (int i = 0; i < n; i++) {
moods[i] = inScanner.nextInt();
}
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.io.BufferedReader;
import java.io.FileWriter;
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.Collection;
import java.util.Collections;
import java.util.HashMap;
import... | 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;
public class Main {
public static void main(String[] args) {
try {
new Main().solve();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
private void solve() throws T... | 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 arr[n + 1];
for (int i = 1; i <= n; i++) {
cin >> arr[i];
}
set<int> s;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {
s.insert(i);
s.insert(n / i);
}
}
s.erase(1);
s.erase(2);
vector<in... | 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.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class C {
private static boolean isPrime(int n) {
if (n <= 2) {
return true;
}
if (n % 2 == 0) {
return false;
}
for (int i = 3; i * i <= n; i += 2) {
... | 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 = 2e5 + 5;
long long int n;
int a[N];
bool check(long long int k) {
for (long long int i = 0; i < k; i++) {
bool f = 1;
for (long long int j = 0; i + j < n; j += k) {
if (!a[i + j]) {
f = 0;
break;
}
}
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 kt[100001];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int n, num;
cin >> n;
for (long long i = 1; i < n + 1; i++) cin >> kt[i];
for (long long i = 3; i < n + 1; i++) {
if (n % i == 0) {
for (int j = 1; j <= n / i; 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 |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
public class RoundTableKnights_CodeForces {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedR... | 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.*;
import static java.lang.Math.*;
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Double.parseDouble;
import static java.lang.String.*;
public class Main {
public static void main(String[] args) thro... | 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 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)
prime = prime[1:]
prime.append(n)
a = [int(i) for i 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 | import java.io.*;
import java.util.StringTokenizer;
import java.util.Scanner;
public class Main {
public static void main(String args[]) throws IOException {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = Integer.par... | 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 factors(n):
farr=[]
for i in range(1,n+1):
if n%i==0:
farr+=[i]
return farr
n=int(input())
arr=list(map(int,input().split()))
sets=set()
for i in range(n):
if arr[i]==1:
sets.add(i)
farr=factors(n)
flag=0
flag2=0
for d in farr:
if n//d>2:
for j in range(d):
if arr[j]==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;
long long n;
bool a[(301 * 1000)];
void check(long long x) {
for (int i = 0; i < x; i++) {
bool mark = 1;
for (int j = i; j < n; j += x)
if (!a[j]) {
mark = 0;
break;
}
if (mark) {
cout << "YES";
exit(0);
}
}
}
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 | import java.util.*;
public class Fku {
static Scanner in =new Scanner(System.in);
static int n,k[];
public static void main(String[] args) {
n=in.nextInt();
k=new int[n+1];
for(int i=1;i<n+1;i++){k[i]=in.nextInt();}
for(int i=1;i<n+1;i++){
if(n%i==0)
if(can(i)){System.out.println("YE... | 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 = 1e5 + 6;
const int M = 1e9 + 7;
const double eps = 1e-7;
int a[N], b[N];
int Int() {
int x;
scanf("%d", &x);
return x;
}
long long Lnt() {
long long x;
scanf("%I64d", &x);
return x;
}
long long Bigmod(long long A, long long B, long long C) {
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;
int a[100005], n;
vector<int> d;
void gen() {
int tmp = n;
for (int i = 1; i <= tmp; i++) {
if (tmp % i == 0) d.push_back(i);
}
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
}
gen();
int sz = d.size();
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 | #include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const double PI = 3.141592653589793;
int n, n2, l, l2, k, i, j, tab[100005], da;
int main() {
scanf("%d", &n);
n2 = n;
for (i = 0; i < n; i++) scanf("%d", &tab[i]);
k = 2;
while (n != 1) {
if (n % k == 0) {
if (k == 2 && n % 4... | 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.io.PrintWriter;
import java.io.StreamTokenizer;
public class C71 {
static StreamTokenizer in = new StreamTokenizer(new BufferedReader(
new InputStreamReader(System.in)));
static PrintWriter out = new PrintWriter(System.ou... | 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.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.BitSet;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper... | 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.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringTokenizer;
public class RoundTableKnights {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
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 | 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 | import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class C {
public static void main(String[] args) throws IOException {
new C().solve();
}
static final boolean DEBUG = System.getProperty("ONLINE_JUDGE") == null;
BufferedReader br;
... | 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 long long N = 200005, INF = 2000000000000000000;
long long power(long long a, long long b, long long p) {
if (a == 0) return 0;
long long res = 1;
a %= p;
while (b > 0) {
if (b & 1) res = (res * a) % p;
b >>= 1;
a = (a * a) % p;
}
return res;
}... | 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 = [0] + [int(x) for x in input().split()]
done = 0
for i in range(1, n + 1):
if n % i or n < 3 * i:
continue
flag = 0
for j in range(1, i + 1):
flag = 1
for k in range(j, n + 1, i):
if a[k] == 0:
flag = 0
break
if... | 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 M = 1e9 + 7;
template <class T>
T ABS(const T& x) {
return x > 0 ? x : -x;
}
long long int gcd(long long int n1, long long int n2) {
return n2 == 0 ? ABS(n1) : gcd(n2, n1 % n2);
}
long long int lcm(long long int n1, long long int n2) {
return n1 == 0 && n2 =... | 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 arr[100100];
int m;
int A[500];
void getDiv() {
int sq = sqrt(n);
A[1] = 1;
m = 1;
for (int i = 2; i <= sq; i++) {
if (n % i == 0) {
m++;
A[m] = i;
if (i * i == n || i == 2) continue;
m++;
A[m] = n / i;
}
}
}
int ca... | 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())
arr = list(map(lambda x: int(x), input().split(" ")))
def solution(n: int, arr: [int]) -> str:
for i in range(3, n + 1):
if n % i != 0: continue
for j in range(0, n // i):
for k in range(j, n, n // i):
if arr[k] == 0:
break
... | 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.*;
import java.io.*;
public class temp
{
public static void main(String[] args)
{
InputReader in = new InputReader(System.in);
PrintWriter pw = new PrintWriter(System.out);
int n = in.nextInt();
int[] p = new int[n];
int and = 1;
boolean flag = false;
for(int i=0;... | 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;
template <typename T>
T gcd(T a, T b) {
if (a == 0) return b;
return gcd(b % a, a);
}
template <typename T>
T pow(T a, T b, long long m) {
T ans = 1;
while (b > 0) {
if (b % 2 == 1) ans = (ans * a) % m;
b /= 2;
a = (a * a) % m;
}
return ans % m;
}
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 | #------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
BUF... | 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 knight[100000];
int is_possible(int t, int n) {
vector<int> r(t, 1);
for (int i = 0; i < n; i++) r[i % t] &= knight[i];
for (int i = 0; i < r.size(); i++)
if (r[i]) return 1;
return 0;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
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 | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
public class C71 {
static StreamTokenizer sc;
public static void main(String[] args) throws IOException{
sc = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
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 | # -*- coding: utf-8 -*-
n = input()
status = map(int, raw_input().split())
frt = False
ors = lambda x, y: x or y
ands = lambda x, y: x and y
b = False
for l in range(1, n/3+1):
if n%l!=0: continue
for i in range(l):
b = True
for j in range(i, n, l):
if status[j] == 0:
... | 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())
moods = list(map(int, input().split()))
good = False
for skip in range(n // 3, 0, -1):
if n % skip != 0:
continue
verts = n // skip
for i in range(skip):
if sum(moods[i + j * skip] for j in range(verts)) == verts:
good = True
if good:
print('YES')
else:
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;
vector<int> vprimes;
int primes[100005];
int arr[100005];
void gen_primes() {
for (int i = 2; i < 100005; i++) {
if (!primes[i]) {
vprimes.push_back(i);
for (int j = i + i; j < 100005; j += i) {
primes[j] = 1;
}
}
}
}
int main() {
gen... | 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 fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
template <typename T>
T POW(T B, T P) {
if (P == 0) return 1;
if (P & 1)
return B * POW(B, P - 1);
else
return (POW(B, P / 2)) * (POW(B, P / 2));
}
long long powmod(long l... | 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()
for i in range(3,n+1):
if n % i > 0:continue
step,ans=n//i,"YES"
for ofs in range(step):
ans="YES"
for j in range(ofs,n,step):
if a[j]=='0':
ans="NO"
break
if ans=="YES":
print(ans)
e... | 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.PrintWriter;
import java.util.Scanner;
import java.util.Vector;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int[] b = new int[n];
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 | //package round65;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
public class C {
Scanner in;
PrintWriter out;
String INPUT = "";
void solve()
{
int n = ni();
int[] a = new int[n];
for(int i = 0;i < n;i++){
a[i] = ni();
}
for(int p = 1;p <= n/3;p++){
if(n % 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.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main {
BufferedReader in;
StringTokenizer st;
PrintWriter out;
int n;
int[] v;
ArrayList<Integer> divisors(int n) {
ArrayList<Integer> ret = new ArrayList<Integer>();
for (int i = 1; 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;
signed main() {
int n;
cin >> n;
int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
vector<int> pr;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
if (i > 2) {
pr.push_back(i);
}
if (i != n / i && (n / i) > 2) {
pr.pus... | 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.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Mahmoud Aladdin
*/
public class Main {
public static void main(String[] args) {
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 | '''
Created on 17.05.2011
@author: Rodion
'''
from string import find
def main():
n = int(raw_input())
a = map(int, raw_input().split())
i = 1
ok = False
while i * i <= n:
if n % i == 0:
ok = ok or check(n / i, a) or check(i, a)
i += 1
print "YES" if ok else "NO"
... | 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 sys
import string
import math
import heapq
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction
def mi(s):
return map(int, s.strip().split())
def lmi(s):
return list(mi(s))
def tmi(s):
return tuple(mi(s))
def mf(f, 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 | #include <bits/stdc++.h>
using namespace std;
const long oo = int(1e9);
const long N = int(1e5) + 5;
long n, a[N];
bool ok(long first) {
for (long i = 1; i <= first; i++) {
bool ok = 1;
for (long j = i; j <= n; j += first)
if (a[j] != 1) ok = 0;
if (ok) return 1;
}
return 0;
}
int main() {
ios... | 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 divisors(n):
i = 2
res = set()
tmp = n
while i * i <= n:
while tmp % i == 0:
tmp //= i
res.add(i)
i += 1
if tmp != 1:
res.add(tmp)
if n % 4 == 0:
res.add(4)
res.discard(2)
return res
def main():
n = int(input())
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 | #include <bits/stdc++.h>
using namespace std;
long long fast_power(long long val, long long deg, long long mod = 1000000007) {
if (!deg) return 1 % mod;
if (deg & 1) return fast_power(val, deg - 1, mod) * val % mod;
long long res = fast_power(val, deg >> 1, mod);
return (res * res) % mod;
}
long long MMI(long l... | 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.List;
import java.util.Scanner;
public class C71 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
List<Integer> goods = new ArrayList<>();
for (int i = 0; i < n; ++i) {
if ... | 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(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((i+1),len(x... | 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 long long eps = 998244353;
const long double inf = 1e-8;
int main() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 1; i * i <= n; ++i) {
if (n % i == 0) {
for (int j = 0; j < i; ++j) {
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;
bool sortinrev(pair<long long, long long> x, pair<long long, long long> y) {
return x.first > y.first;
}
void swap(long long* a, long long* b) {
long long temp = *a;
*a = *b;
*b = temp;
}
long long div_ceil(long long a, long long b) { return (a + b - 1) / b; }
long ... | 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 i, n, j, k, start;
bool f, ff;
cin >> n;
vector<int> a;
a.resize(2 * n);
for (i = 0; i < n; i++) {
cin >> a[i];
a[i + n] = a[i];
}
a[n] = a[0];
k = n / 3;
i = 0;
f = false;
while (!f && i < k) {
i++;
j = 0;
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 | import sys
from collections import defaultdict
def uniqueFactors(N):
factors = defaultdict(list)
for i in range(3, N + 1):
if i in factors:
numList = factors[i]
for factor in numList:
factors[i + factor].append(factor)
else:
factors[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 fast_exp(long long int base, long long int exp1) {
long long int res = 1;
while (exp1 > 0) {
if (exp1 & 1) res = (res * base) % 1000000007;
base = (base * base) % 1000000007;
exp1 /= 2;
}
return res % 1000000007;
}
long long int pr[1000001]... | 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.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.Bi... | 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=input();l=raw_input()[::2];s=set();g=0
for i in range(3,n+1):
if n%i<1 and all(i%j for j in s):s.add(i);g|=i*"1"in{l[j::n/i]for j in range(n/i)}
print"NYOE S"[g::2] | 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 | /**
* https://codeforces.com/problemset/problem/71/C
* #implementation
*/
import java.util.Scanner;
import java.util.HashSet;
import java.util.ArrayList;
public class RoundTableKnights {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Ar... | 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;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> v(n);
for (auto &it : v) {
cin >> it;
}
vector<int> fr;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
int x = 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.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class C071 {
public static void main(String[] args) throws Exception {
BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(r.readLine()... | 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 c71c
{
private final Scanner sc;
private static final boolean debug = true;
static void debug(Object ... objects)
{
if(debug)
System.err.println(Arrays.toString(objects));
}
c71c()
{
sc = new Scanner(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 | #include <bits/stdc++.h>
using namespace std;
int i, j, n, s, k, v, h, curcol = 0, n2, t, c1, fuck;
char a[100500];
bool test(int x) {
int r = n / (n / x);
for (int j = 0; j < r; j++) {
int u = j;
while (u < n && a[u] == 1) u += x;
if (u >= n) return true;
}
return false;
}
int main() {
cin >> 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 | def heras(n): # retorna una lista X donde X[i] es el mayor primo que divide a i
prime_divisors = [1 for _ in range(n)]
for i in range(2, n):
if prime_divisors[i] == 1:
for j in range(i, n, i):
prime_divisors[j] = i
return prime_divisors
n = int(input())
table = [int(x) ... | 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.*;
public class RoundTableKnights {
/**
* @param args
*/
public static void main(String[] args) {
RoundTableKnights rtk = new RoundTableKnights();
}
RoundTableKnights(){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] knights = new int[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 sys
def check(arr, head, dis, n):
if arr[head] != 1:
return 0
pos = head + dis
while pos != head:
if arr[pos] != 1:
return 0
else:
pos += dis
pos %= n
return 1
n = input();
kn = raw_input().split()
for i in range(len(kn)):
kn[i] = int(kn[i])
flag = 0
i = 1
while i * i <= n:
if (n % 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 | #include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 200;
int a[N];
int main() {
int n;
cin >> n;
vector<int> v;
for (int i = 3; i <= n; i++) {
if (n % i == 0) {
v.push_back(i);
}
}
sort(v.begin(), v.end());
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 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.*;
public class RegularPolygon {
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... | 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 | num_knights = int(raw_input())
knight_disposition = [int(x) for x in raw_input().split()]
for i in range(1, num_knights):
if(num_knights%i!=0):
continue
for offset in range(i):
isregular=True
numhit=0
for j in range(offset, num_knights, i):
if knight_disposition[j] =... | 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 beta65c {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int[] arr = new int[N];
for (int i = 0; i < N; i++) {
arr[i] = in.nextInt();
}
//int bound = (int) Math.floor(N/2);
double bound = (double)... | 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 | a=int(input(''))
b=list(map(int,input().split()))
f=0
for i in range(3,a+1):
if(a%i==0):
n=a//i
for j in range(n):
flag=True
for il in range(j,a,n):
if(b[il]==0):
flag=False
break
if flag:
f=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 | import java.util.Scanner;
public class cf_71c {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
boolean[] sides = new boolean[n];
for (int i = 0; i < sides.length; i++) {
sides[i] = in.nextInt()==1;
}
for (int i = 1; i < Math.sqrt(sides.length)+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.util.*;import java.io.*;import java.math.*;
public class Main
{
public static void process()throws IOException
{
int n=ni(),arr[]=new int[n+1];
for(int i=1;i<=n;i++) arr[i]=ni();
ArrayList<Integer> li = new ArrayList<>();
for(int i=2;i<=Math.sqrt(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 | a=int(input(''))
b=list(map(int,input().split()))
f=0
for i in range(3,a+1):
if(a%i==0):
n=a//i
for k in range(n):
f=1
for z in range(k,a,n):
if(b[z]==0):
f=0
break
if(f==1):
break
if(f==1... | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.