input stringlengths 20 127k | target stringlengths 20 119k | problem_id stringlengths 6 6 |
|---|---|---|
n=int(eval(input()))
s=list(map(str,input().split()))
total=[]
for i in range(n):
if s[i] not in total:
total.append(s[i])
print(('Three' if len(total)==3 else 'Four')) | eval(input())
l=list(map(str,input().split()))
print(('Three' if len(set(l))==3 else 'Four')) | p03424 |
N = int(eval(input()))
S = list(map(str, input().split()))
A = 0
for i in range(N):
for j in range(N-1):
for k in range(N-2):
for l in range(N-3):
if S[i] != S[j+1] and S[j+1] != S[k+2]and S[k+2] != S[l+3] and S[l+3] != S[i] and S[j+1] != S[l+3] and S[i] != S[k+2]:
... | N = int(eval(input()))
S = list(map(str, input().split()))
if ("P"and "W" and "G" and "Y") in S:
print("Four")
else:
print("Three")
| p03424 |
import sys
n, *s = sys.stdin.read().split()
def main():
return 'Four' if len(set(s)) == 4 else 'Three'
if __name__ == '__main__':
ans = main()
print(ans) | import sys
n, *s = sys.stdin.read().split()
def main():
print(('Four' if len(set(s)) == 4 else 'Three'))
if __name__ == '__main__':
main() | p03424 |
def main():
N = int(eval(input()))
A = [i for i in input().split()]
ans = ["Three", "Four"]
print((ans[0] if len(set(A)) == 3 else ans[1]))
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
A = {i for i in input().split()}
if "Y" in A:
print("Four")
else:
print("Three")
if __name__ == '__main__':
main()
| p03424 |
n = int(eval(input()))
s = list(map(str,input().split()))
a = len(list(set(s)))
if a==3:
print("Three")
else:
print("Four") | n = int(eval(input()))
s = list(map(str,input().split()))
if "Y" in s:
print("Four")
else:
print("Three") | p03424 |
from collections import Counter
n = eval(input())
s = input().split()
ss = Counter(s)
print(('Three' if len(ss) == 3 else 'Four'))
| n = eval(input())
s = set(input().split())
print(('Three' if len(s) == 3 else 'Four'))
| p03424 |
n = int(eval(input()))
s = input().split()
s = set(s)
print(('Four' if len(s) == 4 else 'Three')) | n = int(eval(input()))
s = input().split()
print(('Four' if len(set(s)) == 4 else 'Three')) | p03424 |
n=int(eval(input()))
t = input().split()
count = []
memo = 0
for i in t:
if i in count:
continue
count.append(i)
memo += 1
if memo == 3:
print('Three')
else:
print('Four') | n = int(eval(input()))
s = list(map(str,input().split()))
if "Y" in s:
print("Four")
else:
print("Three") | p03424 |
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")... | #!/usr/bin/python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cac... | p03424 |
n = int(eval(input()))
s = list(input().split())
P = s.count("P")
W = s.count("W")
G = s.count("G")
print(("Three" if n==P+W+G else "Four")) | eval(input())
s = list(map(str,input().split()))
print(("Three" if len(set(s))==3 else "Four")) | p03424 |
N = int(eval(input()))
l = list(map(str, input().split()))
s = set(l)
if len(s)==3:
print('Three')
else:
print('Four') | n = int(eval(input()))
l = list(input().split())
if len(set(l)) == 4:
print('Four')
else:
print('Three') | p03424 |
from collections import Counter
N = eval(input())
color_list = [i for i in input().split()]
result = len(Counter(color_list))
if result == 3:
result = 'Three'
elif result == 4:
result = 'Four'
print(result) | N = input()
color_list = [i for i in input().split()]
print('Four') if 'Y' in color_list else print('Three')
| p03424 |
N = int(eval(input()))
S = input().split()
print(('Three' if len(set(S))==3 else 'Four')) | N = int(eval(input()))
S = set(input().split())
print(('Four' if len(S)==4 else 'Three')) | p03424 |
N = int(eval(input()))
S = list(map(str, input().split()))
candy_list = ['P', 'W', 'G', 'Y']
answer = 0
for i in range(4):
if candy_list[i] in S:
answer += 1
if answer == 3:
print('Three')
if answer == 4:
print('Four') | N = int(eval(input()))
S = list(map(str, input().split()))
if 'Y' in S:
answer = 'Four'
else:
answer = 'Three'
print(answer) | p03424 |
n = int(eval(input()))
flag = False
s = input().split(" ")
for c in s:
if(c == "Y"):
flag = True
if(flag):
print("Four")
else:
print("Three") | n = int(eval(input()))
s = input().split()
for i in s:
if(i == 'Y'):
print('Four')
exit()
print('Three')
| p03424 |
N = int(eval(input()))
S = list(set(input().split()))
if(len(S) == 4):
print("Four")
else:
print("Three") | N = int(eval(input()))
S = input().split()
if(len(set(S)) == 4):
print("Four")
else:
print("Three") | p03424 |
n = int(eval(input()))
ls = [s.rstrip() for s in input().split()]
if ls.count('Y') > 0:
print('Four')
else:
print('Three') | eval(input())
ls = list(input().split())
if ls.count('Y') > 0:
print('Four')
else:
print('Three') | p03424 |
n=int(eval(input()))
print(("Three" if len(set(list(input().split())))==3 else "Four")) | n=eval(input())
print(("Three" if len(set(list(input().split())))==3 else "Four")) | p03424 |
eval(input())
s=input().split()
print(('Four' if 'Y' in s else 'Three')) | n=int(eval(input()))
s=set(input().split())
print(('Three' if len(s)==3 else 'Four')) | p03424 |
N = int(eval(input()))
S = list(map(str,input().split()))
if S.count("Y") == 0:
print("Three")
else:
print("Four") | N = int(eval(input()))
for i in (list(input().split())):
if i == "Y":
print("Four")
exit()
print("Three") | p03424 |
n=int(eval(input()))
s=list(input().split())
if len(set(s))==3:
print("Three")
if len(set(s))==4:
print("Four") | N = int(eval(input()))
A = input().split()
if len(set(A)) <= 3:
print("Three")
else:
print("Four")
| p03424 |
N=int(eval(input()))
S=list(map(int,input().split()))
while len(S)!=1:
S.sort()
if S[1]%S[0]==0:
S.pop(1)
else:
S[1]=S[1]%S[0]
if S[0]==1:
print((1))
exit()
print((S[0])) | import math
N=int(eval(input()))
S=list(map(int,input().split()))
F=S[0]
for i in range(N-1):
F=math.gcd(F,S[i+1])
print(F) | p03127 |
#dpでできないかな?
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop,... | #float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import h... | p03127 |
import sys
sys.setrecursionlimit(10**6)
def f(a,*b):
if len(b)>1:
return f(a,f(*b))
b=b[0]
if b:
return f(b,a%b)
return a
n=int(eval(input()))
a=list(map(int,input().split()))
print((f(*a))) | def f(a,b):
if b:
return f(b,a%b)
return a
n=int(eval(input()))
a=list(map(int,input().split()))
p=f(a[0],a[1])
for i in a:
p=f(p,i)
print(p) | p03127 |
n = int(eval(input())) #整数
a = [int(i) for i in input().split() ]
a = list(set(a))
a.sort()
while len(a) > 1:
while (a[0] < a[1]):
a[1] %= a[0]
a = list(set(a))
a.sort()
if a[0] == 0:
a.pop(0)
if a[0] == 1:
break
print((a[0])) | n = int(eval(input())) #整数
a = [int(i) for i in input().split() ]
a = list(set(a))
a.sort()
while len(a) > 1:
while (a[0] < a[1]):
a[1] %= a[0]
x = a[1]
a[1] = a[0]
a[0] = x
if a[0] == 0:
a.pop(0)
if a[0] == 1:
break
print((a[0])) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort(reverse=True)
denominator = 0
numerator = 1
while A[numerator] != 0:
A[denominator] = A[denominator] % A[numerator]
if A[denominator] == 0:
denominator += 1
numerator += 1
if denominator >= N or numerator >= ... | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
if a % b == 0:
return b
else:
return gcd(b, a%b)
ans = gcd(A[0], A[1])
if N > 2:
for i in range(2, N):
ans = gcd(ans, A[i])
print(ans) | p03127 |
import math
N = int(eval(input()))
A = [int(x) for x in input().split()]
x = A[0]
for a in A:
x = math.gcd(x, a)
print(x)
|
import math
N = int(eval(input()))
A = [int(x) for x in input().split()]
ans = A[0]
for a in A[1:]:
ans = math.gcd(a, ans)
print(ans)
| p03127 |
n = int(eval(input()))
a = list(map(int, input().split()))
if len(set(a)) == 1:
print((a[0]))
else:
a.sort()
count = 0
while(1):
count = count + 1
for i in range(1, len(a)):
x = a[i] + count
for j in range(i):
x = x % a[i-1-j]
... | n = int(eval(input()))
a = list(map(int, input().split()))
def gcd(a, b):
if a <= b:
if b % a == 0:
return a
else:
return(gcd(b % a, a))
else:
if a % b == 0:
return b
else:
return(gcd(a % b, b))
ans = gcd(a[0], ... | p03127 |
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
N = int(eval(input()))
A = list(map(int,input().split()))
A.sort(reverse=True)
a = A[0]
for i in range(1,N):
a = gcd(a,A[i])
print(a)
| def gcd(a, b):
if b > a:
a,b = b,a
if b == 0:
return a
else:
return gcd(b, a % b)
N = int(eval(input()))
A = list(map(int,input().split()))
a = A[0]
for i in range(1,N):
a = gcd(a,A[i])
print(a)
| p03127 |
def divisor(n):
i = 1
table = []
while i * i <= n:
if n%i == 0:
table.append(i)
table.append(n//i)
i += 1
table = list(set(table))
return table
def main():
n = int(eval(input()))
a = list(map(int, input().split()))
ans = set(d... | def main():
n = int(eval(input()))
a = list(map(int, input().split()))
m = min(a)
next_m = m
count = 0
while count != n:
m = next_m
count = 0
pre = a[0]
for i in range(n):
if a[i] == pre:
count += 1
a[i] %= m
... | p03127 |
N=int(eval(input()))
A=list(map(int,input().split()))
while len(set(A))!=1:
#for i in range(2):
A.sort()
for i in range(len(A)-1):
if A.count(0):
A.remove(0)
break
A[i+1]=A[i+1]%A[0]
print((max(A))) | N=int(eval(input()))
A=list(map(int,input().split()))
def gcd(a,b):
while b:
a,b=b,a%b
return a
A.sort()
y=A[0]
for i in range(1,N):
y=gcd(y,A[i])
print(y) | p03127 |
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import collections
import itertools
import bisect
import heapq
from heapq import heappush
from heapq import heappop
# from itertools import accu... |
# import numpy as np
# import numpypy as np
import sys
import math
import string
import fractions
import re
import array
import copy
import functools
import operator
import collections
import itertools
import bisect
import heapq
from heapq import heappush
from heapq import heappop
# from iter... | p03127 |
n = int(eval(input()))
a = list(map(int,input().split()))
def f(a,b):
if b==0:
return a
else:
return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
for j in range(i+1,len(a)):
ans = min(ans,f(a[i],a[j]))
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
memo = {}
def f(a,b):
if b==0:
return a
else:
return f(b,a%b)
a = sorted(a)
ans = float('inf')
for i in range(len(a)-1):
ans = min(ans,f(a[i],a[i+1]))
print(ans) | p03127 |
N=int(eval(input()))
HP=list(map(int,input().split()))
a=HP[0]
b=HP[1]
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b)
(x, lastx) = (lastx - q * x, x)
(y, lasty) = (lasty - q * y, y)
tmp=a
for i in range(1,N-1):
a=tmp
b=HP[i+1]
... | import sys
N=int(eval(input()))
HP=list(map(int,input().split()))
a=HP[0]
b=HP[1]
(x, lastx) = (0, 1)
(y, lasty) = (1, 0)
while b != 0:
q = a // b
(a, b) = (b, a % b)
(x, lastx) = (lastx - q * x, x)
(y, lasty) = (lasty - q * y, y)
tmp=a
for i in range(1,N-1):
a=tmp
... | p03127 |
# coding: utf-8
import sys
# import bisect
# import math
# import itertools
# import numpy as np
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
... | # coding: utf-8
import sys
# import bisect
# import math
# import itertools
# import numpy as np
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
... | p03127 |
# coding: utf-8
import sys
# import bisect
# import math
# import itertools
# import numpy as np
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
... | def gcd(x, y):
# ユークリッドの互除法で最大公約数を見つける
if y == 0:
return x
else:
return gcd(y, x % y)
n = int(eval(input()))
a = list(map(int, input().split()))
# 最大公約数の1番小さい値を取る
# a[0]との最大公約数を全パターン取って、小さい方をansに入れる
ans = min(gcd(a[0], x) for x in a)
print(ans)
| p03127 |
import bisect
import collections
n = int(eval(input()))
s = list(map(int,input().split()))
s.sort()
while len(s) > 1:#最も体力のあるのが攻撃を受ける
temp = s.pop()
for j in s:
damege = (temp//j)*j
if temp != 0 and temp != damege:
index = bisect.bisect_left(s,temp-damege)
s.insert(i... | import math
n = int(eval(input()))
a = list(map(int,input().split()))
tmp = a[0]
for i in range(1,len(a)):
tmp = math.gcd(tmp,a[i])
print(tmp) | p03127 |
from itertools import combinations
N=int(eval(input()))
A=[i for i in map(int,input().split())]
def gcd(x,y):
while y!=0:
x , y = y , x%y
return x
ans=1e10
for comb in combinations(A,2):
ans=min(ans,gcd(comb[0],comb[1]))
print(ans) | from itertools import combinations
N=int(eval(input()))
A=[i for i in map(int,input().split())]
def gcd(x,y):
while y!=0:
x , y = y , x%y
return x
ans=A[0]
for i in range(1,len(A)):
ans=min(ans,gcd(ans,A[i]))
print(ans) | p03127 |
n=int(eval(input()))
a_s=list(map(int,input().split()))
while True:
a_s=set(a_s)
a_s.discard(0)
a_s=list(a_s)
index=a_s.index(min(a_s))
for i in range(len(a_s)):
if i!=index and min(a_s)!=0:
a_s[i]=a_s[i]%min(a_s)
if len(a_s)==1:
break
print((sum(a_s))) | n=int(eval(input()))
a_s=list(map(int,input().split()))
def sakujo(a_list):
for i in range(len(a_list)):
if a_list[i]!=0:
end=i
break
return a_list[i:]
while True:
a_s.sort()
a_s=sakujo(a_s)
if len(a_s)==1:
break
for i in range(1,len(a_s))... | p03127 |
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 0
for i in range(min(A),0,-1):
if all( A[c] % i == 0 for c in range(N)):
ans = i
break
print(ans) | N = int(eval(input()))
A = list(map(int,input().split()))
A = sorted(A) # とりあえず並び替えておく
tmp = 0
for i in range(N-1):
while A[i]>0:
tmp = A[i]
A[i] = A[i+1] % A[i]
A[i+1] = tmp
print((A[N-1])) | p03127 |
n = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
while len(A) > 1:
a = [A[0]]
for i in range(1, len(A)):
if A[i]%A[0] == 0: continue
else: a.append(A[i]%A[0])
A = sorted(a)
print((A[0])) | n = int(eval(input()))
A = sorted(list(map(int, input().split())))
while len(A) > 1:
A = sorted([i%A[0] for i in A if i%A[0]!=0] + [A[0]])
print((A[0])) | p03127 |
n, *a = list(map(int, open(0).read().split()))
a.sort()
ans = 1e10
for i in range(1, n):
x, y = a[0], a[i]
while y%x:
y -= y//x*x
x, y = y, x
ans = min(ans, x)
print(ans) | def gcd(a, b):
if(a==0): return b
if a<b: a,b=b,a
while b: a,b=b,a%b
return a
n, *a = list(map(int, open(0).read().split()))
g = 0
for i in a: g = gcd(g, i)
print(g) | p03127 |
n = int(eval(input()))
a = list(map(int,input().split()))
b = [0]*n
ans = min(a)
for j in range(min(a)):
for i in range(n):
b[i] = a[i]%ans
if max(b) == 0:
break
else:
ans = max(b)
print(ans) | n = int(eval(input()))
A = list(map(int,input().split()))
#ユーグリッドの互除法で、a,bを与えて、aをbで割ってあまりを計算する
#あまりがないときは、最後に割った数を返す(最大公約数)
#あまりがあるときは、bにあまりを入れて、再び計算する
def gcd(a,b):
if b == 0:
return a
return gcd(b,a%b)
x = A[0]
for i in A[1:]:
x = gcd(x,i)
print(x) | p03127 |
# 2019-11-12 15:53:47(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# ... | import sys
from functools import reduce
def gcd(a, b):
while b:
a, b = b, a % b
return abs(a)
n, *a = list(map(int, sys.stdin.read().split()))
def main():
return reduce(gcd, a)
if __name__ == '__main__':
ans = main()
print(ans) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
R = A[0]
while True:
C = A.copy()
B = [A[0]] + [A[i+1] - A[i] for i in range(len(A)-1) if A[i+1] > A[i]]
B = list(set(B))
B.sort()
R = min(R, B[0])
if C == B:
break
elif R == 1:
break
... | N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
R = A[0]
while True:
C = A.copy()
B = [A[0]] + [a for a in [A[i+1] % A[i] for i in range(len(A)-1)] if a > 0]
B = list(set(B))
B.sort()
R = min(R, B[0])
if C == B:
break
elif R == 1:
break
... | p03127 |
n=int(eval(input()))
a=list(map(int,input().split()))
import copy
for i in range(10**4):
a.sort()
wari=a[-2]
if wari==0:
print((a[-1]))
break
a[-1]=a[-1]%wari
| n=int(eval(input()))
a=list(map(int,input().split()))
def gcd(a,b):
aa=max(a,b)
bb=min(a,b)
cc=aa%bb
return gcd(bb,cc) if cc else bb
p=gcd(a[0],a[1])
for i in range(2,n):
p=gcd(p,a[i])
print(p)
| p03127 |
# -*- coding: utf-8 -*-
import fractions
N = int(eval(input()))
A = list(map(int, input().split()))
def calc(monsters):
if len(monsters) == 1:
return monsters[0]
min_monster = min(monsters)
min_index = monsters.index(min_monster)
new_monsters = []
for i in range(len(monster... | # -*- coding: utf-8 -*-
N = int(eval(input()))
A = list(map(int, input().split()))
def calc(monsters):
if len(monsters) == 1:
return monsters[0]
min_monster = min(monsters)
min_index = monsters.index(min_monster)
new_monsters = []
for i in range(len(monsters)):
if i... | p03127 |
def gcd(a,b):
if b==0:
return a
else:
return gcd(b,a%b)
N=int(eval(input()))
A=list(map(int,input().split()))
g=A[0]
for i in range(1,N):
g=gcd(g,A[i])
print(g) | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(x, y):
while y:
x, y = y, x % y
return x
answer = A[0]
for i in range(1, N):
answer = gcd(A[i], answer)
print(answer) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(x, y):
while y:
x, y = y, x % y
return x
answer = A[0]
for i in range(1, N):
answer = gcd(A[i], answer)
print(answer) | import sys
input = sys.stdin.buffer.readline
N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(x, y):
while y:
x, y = y, x % y
return x
answer = A[0]
for i in range(1, N):
answer = gcd(A[i], answer)
print(answer) | p03127 |
from collections import Counter
def factor(N):
ret = []
i = 2
while N > 1:
if N % i == 0:
ret.append(i)
N //= i
else:
i += 1
return ret
def solve(N, As):
iter = Counter(factor(min(As)))
for a in As:
for k, v in l... |
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
assert (gcd(10, 3) == 1)
def solve(N, As):
k = min(As)
for a in As:
k = gcd(k, a)
return k
if __name__ == "__main__":
N = int(eval(input()))
As = list(map(int, input().split(" ")))
print((solve(N... | p03127 |
def main():
N = int(eval(input()))
A = [int(i) for i in input().split()]
minA = min(A)
while any(a % minA for a in A):
for i in range(N):
if A[i] % minA:
A[i] %= minA
minA = min(A)
print(minA)
if __name__ == '__main__':
main()
| def main():
N = int(eval(input()))
A = [int(i) for i in input().split()]
def gcd(x, y):
if y == 0:
return x
while y != 0:
x, y = y, x % y
return x
g = A[0]
for a in A[1:]:
g = gcd(g, a)
print(g)
if __name__ == '__main__... | p03127 |
N = int(eval(input()))
#A = [int(i) for i in input().split()]
A = list(map(int,input().split()))
def gcp(a,b):
if b == 0:
return a
else:
a,b = b,a%b
return gcp(a,b)
a = A[0]
for i in range(1,N):
a = gcp(a,A[i])
print(a) | N = int(eval(input()))
#A = [int(i) for i in input().split()]
A = list(map(int,input().split()))
def gcp(a,b):
if b == 0:
return a
else:
return gcp(b,a%b)
a = A[0]
for i in range(1,N):
a = gcp(a,A[i])
print(a) | p03127 |
N = int(eval(input()))
monsters = list(map(int, input().split()))
monsters.sort(reverse=True)
#print(monsters)
ans = min(monsters)
while ans > 0:
maxnum = max(monsters)
minnum = min(monsters)
maxidx = monsters.index(maxnum)
if maxnum % minnum == 0:
del monsters[maxidx]
i... | N = int(eval(input()))
monsters = list(map(int, input().split()))
monsters.sort() # 昇順
minnum = monsters[0]
cnt = len(monsters)
minidx = 0
while cnt > 1:
for i in range(cnt - 1, 0, -1):
monsters[i] = monsters[i] % monsters[0]
if monsters[i] == 0:
del monsters[i]
... | p03127 |
N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
a = min(A)
A = set(x - a if x != a else a for x in A)
if 1 in A:
A = {1}
print((list(A)[0])) | N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
a = min(A)
A = set(x % a if x % a != 0 else a for x in A)
if 1 in A:
A = {1}
print((list(A)[0])) | p03127 |
N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
a = min(A)
A = set(x % a if x % a != 0 else a for x in A)
if 1 in A:
A = {1}
print((list(A)[0])) | N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
a = min(A)
A = set(x % a if x % a != 0 else a for x in A)
print((list(A)[0])) | p03127 |
n = int(eval(input()))
a = list(map(int, input().split()))
while True:
a.sort()
t = sum(a)
for i in range(1, len(a)):
if a[i] % a[0] == 0:
a[i] = a[0]
else:
a[i] = a[i] % a[0]
if sum(a) == t:
break
print((a[0])) | N = int(eval(input()))
A = list(map(int, input().split()))
while True:
A.sort()
t = sum(A)
for i in range(1, N):
if A[i] % A[0] == 0:
A[i] = A[0]
else:
A[i] = A[i] % A[0]
if sum(A) == t:
break
print((A[0]))
| p03127 |
n,*h=list(map(int,open(0).read().split()))
while len(h)>1:
kh=set()
for x in h:
mn = min(h)
md=x%mn
if md!=0:
kh.add(md)
if len(kh)==mn-1:
break
kh.add(mn)
h=kh
print(mn) | def gcd(a,b):
if a%b==0:
return b
else:
return gcd(b,a%b)
n,*h=list(map(int,open(0).read().split()))
gh=gcd(h[0],h[1])
for i in range(2,n):
gh=gcd(h[i],gh)
print(gh) | p03127 |
from math import gcd
n = int(eval(input()))
a = list(map(int,input().split()))
p = a[0]
for i in range(1,n):
p = gcd(p,a[i])
print(p) | from math import gcd
n = int(eval(input()))
a = list(map(int,input().split()))
ans = a[0]
for i in a[1:]:
ans = gcd(ans,i)
print(ans) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
ans = 10 ** 10
while min(A) != ans:
ans = min(A)
for i, a_i in enumerate(A):
if a_i > ans:
A[i] = a_i % ans
if A[i] == 0:
del A[i]
print(ans) | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def gcd_arr(a):
ans = a[0]
for i, a_i in enumerate(a):
ans = gcd(ans, a_i)
return ans
print((gcd_arr(A))) | p03127 |
import random
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N... | N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N-1] % A[N-4] !=... | p03127 |
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N-1] % A[N-4] !=... | N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N-1] % A[N-4] !=... | p03127 |
N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N-1] % A[N-4] !=... | N = int(eval(input()))
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
iii += 1
if A[N-1] % A[N-2] != 0:
A[N-1] = A[N-1] % A[N-2]
elif N >= 3 and A[N-1] % A[N-3] != 0:
A[N-1] = A[N-1] % A[N-3]
elif N >= 4 and A[N-1] % A[N-4] !=... | p03127 |
import math
n = int(eval(input()))
A = tuple(map(int, input().split()))
g = A[0]
for a in A[1:]:
g = math.gcd(g, a)
print(g)
| n = int(eval(input()))
A = tuple(map(int, input().split()))
ma = min(A)
while True:
ra = set([a%ma for a in A if a%ma > 0])
if len(ra) == 0:
print(ma)
break
minra = min(ra)
if ma == minra:
print(ma)
break
ma = minra
| p03127 |
N = int(eval(input()))
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
while len(M) > 1:
M = [mini] + [x-mini for x in M[1:] if x % mini != 0]
M.sort()
if 1 in M:
mini=1
break
mini = min(mini,M[0])
print(mini)
| N = int(eval(input()))
An = [int(n) for n in input().split()]
M = sorted(set(An))
mini=M[0]
while len(M) > 1:
M = [mini] + [x%mini for x in M[1:] if x % mini != 0]
M.sort()
if 1 in M:
mini=1
break
mini = min(mini,M[0])
print((M[0]))
| p03127 |
def INT():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
from collections import deque
N = INT()
A = LI()
A.sort()
while True:
mod = A[0]
flg = True
ans = A[0]
tmp = deque([A[0]])
i... | def INT():
return int(eval(input()))
def MI():
return list(map(int, input().split()))
def LI():
return list(map(int, input().split()))
from math import gcd
N = INT()
A = LI()
A.sort()
ans = A[0]
all_can_div = True
for i in range(1, N):
A[i] = gcd(A[i], ans)
if A[i] !=... | p03127 |
n = int(eval(input()))
a = [int(i) for i in input().split()]
#%%
# n, a = 4, [2, 10, 8, 40]
#%%
#%%
#%%
while len(a) >= 2:
a.sort()
for i in range(len(a) -1, 0, -1):
a[i] = a[i] % a[0]
if a[i] == 0:
a.remove(a[i])
#%%
print((a[0]))
#%%
| n = int(eval(input()))
a = [int(i) for i in input().split()]
def euclid_lcf(a, b):
if b < a:
a, b = b, a
if b % a == 0:
return a
else:
r = b % a
return euclid_lcf(a, r)
com_factor = euclid_lcf(a[0], a[1])
if len(a) == 2:
print(com_factor)
else:
... | p03127 |
import sys
sys.setrecursionlimit(1000000)
def gcd(i,j):
if i>j:
i,j=j,i
if j%i==0:
return i
return gcd(j-i,i)
n=int(eval(input()))
l=[int(i) for i in input().split()]
g=gcd(l[0],l[1])
for i in range(2,len(l)):
g=gcd(g,l[i])
print(g) | import sys
sys.setrecursionlimit(1000000)
def gcd(i,j):
if i>j:
i,j=j,i
if j%i==0:
return i
return gcd(j-i,i)
n=int(eval(input()))
l=[int(i) for i in input().split()]
l.sort()
g=gcd(l[0],l[1])
for i in range(2,len(l)):
g=gcd(g,l[i])
print(g) | p03127 |
import itertools
import copy
def main():
N = int(eval(input()))
A = set(list(map(int, input().split())))
com0 = None
while True:
com = list(itertools.combinations(A,2))
if com0 == com:
break
com0 = copy.copy(com)
for q in com:
if q[... | def gcm(a,b):
while b != 0:
a, b = b, a % b
return a
def gcm_list(a):
ans = a[0]
l = len(a)
for i in range(1, l):
ans = gcm(ans, a[i])
return ans
N = int(eval(input()))
A = list(map(int, input().split()))
print((gcm_list(A)))
| p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
A.sort()
while A[-2] != 0:
A[-1] -= A[-2] * (A[-1] // A[-2])
A.sort()
print((A[-1])) | N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
minA = min(A)
tempA = []
tempA.append(minA)
for a in A:
mod = a % minA
if mod != 0:
tempA.append(mod)
A = tempA
print((A[0])) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
minA = min(A)
tempA = []
tempA.append(minA)
for a in A:
mod = a % minA
if mod != 0:
tempA.append(mod)
A = tempA
print((A[0])) | N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
minA = min(A)
tempA = set()
tempA.add(minA)
for a in A:
mod = a % minA
if mod != 0:
tempA.add(mod)
A = tempA
print((list(A)[0])) | p03127 |
N = int(eval(input()))
A = set(map(int, input().split()))
while len(A) > 1:
minA = min(A)
tempA = set()
tempA.add(minA)
for a in A:
mod = a % minA
if mod != 0:
tempA.add(mod)
A = tempA
print((list(A)[0])) | N = int(eval(input()))
A = list(map(int, input().split()))
while len(A) > 1:
minA = min(A)
tempA = []
tempA.append(minA)
for a in A:
mod = a % minA
if mod > 0:
tempA.append(mod)
A = tempA
print((A[0]))
| p03127 |
from queue import PriorityQueue
N = int(eval(input()))
A = list(map(int, input().split()))
q = PriorityQueue()
for a in A:
q.put(a)
x = q.get()
while not q.empty():
y=q.get()
if y == 0:
continue
q.put(x % y)
x = y
print(x) | from queue import PriorityQueue
N = int(eval(input()))
A = list(map(int, input().split()))
q = PriorityQueue()
for a in A:
q.put(-a)
x = -q.get()
while not q.empty():
y = -q.get()
if y == 0:
break
q.put(-(x % y))
x = y
print(x) | p03127 |
import sys
n = int(eval(input()))
a = list(map(int, input().split()))
sys.setrecursionlimit(10 ** 5)
def cut(l):
l.sort()
nokori = [l[0]]
for i in range(1, len(l)):
b = l[i] % l[0]
if b != 0:
nokori.append(b)
if len(nokori) != 1:
return cut(nokori)
... | import sys
n = int(eval(input()))
al = list(map(int, input().split()))
sys.setrecursionlimit(10 ** 5)
def gcd(a, b):
if b < a:
a, b = b, a
if b % a == 0:
return a
else:
return gcd(a, b % a)
def gcdl(num, n):
ans = num[0]
for i in range(n):
ans ... | p03127 |
N = int(eval(input()))
A = [int(_) for _ in input().split()]
m = min(A)
if m == 1:
print(m)
else:
while m > 0:
m = min(A)
for i in range(0,len(A)):
if A[i] != m:
A[i] = A[i]%m
z = A.count(0)
for j in range(z):
A.remove(0)
... | N = int(eval(input()))
A = [int(_) for _ in input().split()]
m = min(A)
while m > 0:
for i in range(0,len(A)):
if A[i] != m:
A[i] = A[i]%m
z = A.count(0)
A = sorted(A)[z:]
m = A[0]
if m == 1:
break
else:
if [_%m for _ in A] == [0]*len(A):
... | p03127 |
N = int(eval(input()))
A = list(map(int,input().split()))
def gcd(a,b):
while b!=0:
a,b=b,a%b
return a
gcd_a = A[0]
for i in A:
gcd_a = gcd(gcd_a,i)
print(gcd_a) | from math import gcd
N = int(eval(input()))
A = list(map(int,input().split()))
g = A[0]
for i in A:
g = gcd(g,i)
print(g)
| p03127 |
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math
def readInt():
return int(eval(input()))
def readInts():
return list(map(int, input().split()))
def readChar():
return eval(input())
def readChars():
return input().split(... | import math;eval(input());a=list(map(int,input().split()));d=a[0]
for i in a:d=math.gcd(i,d)
print(d) | p03127 |
n=int(eval(input()))
l=sorted(list(map(int,input().split())))
m=min(l)
l2=[]
l3=[]
for i in range(1,int(m**(1/2)+1)):
if m%i==0:
l2.append(i)
if i!=m//i:
l2.append(m//i)
for i in l2:
b=True
for j in l:
if j%i==0:
pass
else:
b=False
if b:
... | def gcd(n,m):
a=min(n,m)
b=max(n,m)
while a!=0:
b,a=a,b%a
return b
n=int(eval(input()))
l=list(map(int,input().split()))
ans=l[0]
for i in range(1,n):
ans=gcd(ans,l[i])
print(ans) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
As = sorted(A)
As = [a%As[0] if a%As[0] != 0 else As[0] for a in As]
As = sorted(As)
def judge(tmp_one, tmp_two):
flg = 1
while flg:
if tmp_two%tmp_one == 0:
tmp_two = tmp_one
else:
tmp_two = tmp_... | N = int(eval(input()))
A = list(map(int, input().split()))
def gcd(n, m):
if n < m:
temp = n
n = m
m = temp
def ecd(n, m):
if n % m == 0:
return m
else:
temp = n % m
a = ecd(m, temp)
return a
... | p03127 |
n = int(eval(input()))
a = list(map(int,input().split()))
while len(a)!=1:
a = sorted(a)
a = [i%min(a) for i in a[1:]]+[min(a)]
a = [i for i in a if i!=0]
print((min(a))) | n = int(eval(input()))
a = list(map(int,input().split()))
def gcd(x,y):
if x<y:
x,y = y,x
if y==0:
return x
if x%y==0:
return y
else:
return gcd(y,x%y)
ans = a[0]
for i in a:
ans = gcd(ans,i)
print(ans) | p03127 |
def gcd(a,b):
if a < b:
return gcd(b,a)
else:
if a%b == 0:
return b
else:
return gcd(b,a%b)
N = int(eval(input()))
src = sorted(list(map(int,input().split())))
ans = src[0]
for i in range(1,N)[::-1]:
ans = gcd(ans,src[i])
print(ans) | def Gcd(a,b):
if a < b:
return Gcd(b,a)
else:
if a%b:
return Gcd(b,a%b)
else:
return b
N = int(eval(input()))
arr = list(map(int,input().split()))
gcd = arr[0]
for i in arr:
gcd = Gcd(gcd,i)
print(gcd) | p03127 |
def gcd(x,y):
if y==0:
return x
else:
return gcd(y,x%y)
n=int(eval(input()))
a=list(map(int,input().split()))
a=list(sorted(a))
g=a[0]
for aa in a:
g=gcd(g,aa)
print(g)
| def gcd(x, y):
if y == 0: return x
return gcd(y, x % y)
N = int(eval(input()))
a = list(map(int, input().split()))
g = a[0]
for aa in a:
g = gcd(g, aa)
print(g)
| p03127 |
from queue import PriorityQueue
N = int(eval(input()))
A = list(map(int, input().split()))
q = PriorityQueue()
for a in A:
q.put(-a)
x = -q.get()
while not q.empty():
y = -q.get()
if y == 0:
break
q.put(-(x % y))
x = y
print(x) | from queue import PriorityQueue
N = int(eval(input()))
A = list(map(int, input().split()))
q = PriorityQueue()
for a in A:
q.put(a)
x = q.get()
while not q.empty():
y=q.get()
if y == 0:
continue
q.put(x % y)
x = y
print(x) | p03127 |
from math import gcd
n = int(eval(input()))
a = list(map(int, input().split()))
for i in range(n-1):
a[i+1] = gcd(a[i], a[i+1])
print((a[n-1])) | from math import gcd
n=int(eval(input()))
a=list(map(int,input().split()))
res=a[0]
for i in range(1,n):
res=gcd(res,a[i])
print(res) | p03127 |
import math
def process(number_list):
left, point = number_list[0], number_list[-2]
if left == 1:
print((1))
return 0
yojo = number_list[-1] % left
point -= yojo
right = left * (math.ceil(point / left) - 1) + yojo
if right == 0:
number_list.pop(-1)
if... | import math
def process(number_list):
left, point = number_list[0], number_list[-2]
if left == 1:
print((1))
return 0
right = number_list[-1] % left
number_list.pop(-1)
if right == 0:
if len(number_list) == 1:
print((number_list[0]))
retur... | p03127 |
#!usr/bin/env python3
from collections import defaultdict
import math
import bisect
import random
def LI(): return list(map(int, input().split()))
def II(): return int(eval(input()))
def LS(): return input().split()
def S(): return list(eval(input()))
def IIR(n): return [II() for i in range(n)]
def LIR(n): re... | #!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, ... | p03127 |
def gcd(a, b):
while b > 0:
a, b = b, a%b
return a
n = int(eval(input()))
enemy = list(set(map(int,input().split())))
if len(enemy)==1:
print((enemy[0]))
else:
enemy.sort()
min_n = 10**10
for i in range(len(enemy)-1):
min_n = min(min_n,gcd(enemy[i],enemy[i+1]))
print(m... | def gcd(x,y):
if x%y==0: return y
else: return gcd(y,x%y)
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
ans = a[0]
for i in range(1,n):
ans = min(ans,gcd(ans,a[i]))
print(ans) | p03127 |
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
gcd = a[-1]
def Euclid(n1,n2):
if n1 % n2 == 0:
return n2
return Euclid(n2,n1%n2)
for i in range(n-1):
gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)
| n = int(eval(input()))
a = list(map(int,input().split()))
gcd = a[-1]
def Euclid(n1,n2):
if n1 % n2 == 0:
return n2
return Euclid(n2,n1%n2)
for i in range(n-1):
gcd = Euclid(gcd,a[(-1)*(i+2)])
print(gcd)
| p03127 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import bisect
def solve():
n = int(eval(input()))
al = [int(i) for i in input().split()]
al.sort()
while len(al) > 1:
p = al[-1] % sum(al[:-1])
q = al[-1]
al = al[:-1]
if p == 0:
continue
if ... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
def gcd(a, b):
if a < b:
a,b = b,a
while b > 0:
r = a % b
a,b = b,r
return a
def arrgcd(a):
alen = len(a)
if alen == 3:
return gcd(a[0], gcd(a[1], a[2]))
elif alen == 2:
return gcd(a[0], a[1])... | p03127 |
# coding: utf-8
import sys
import collections
N = int(sys.stdin.readline())
monster = [int(a) for a in sys.stdin.readline().strip().split()]
monster.sort()
while len(monster)>1:
monster[1] %= monster[0]
if monster[1] == 0:
monster.pop(1)
monster.sort()
print((monster[0])) | # coding: utf-8
import sys
import collections
N = int(sys.stdin.readline())
monster = [int(a) for a in sys.stdin.readline().strip().split()]
monster.sort()
while len(monster)>1:
for i in range(1,len(monster)):
monster[i] %= monster[0]
monster.sort()
while monster[0]==0:
mons... | p03127 |
N=int(eval(input()))
L=list(map(int,input().split()))
def f(l, s):
return s if l % s == 0 else f(s, l % s)
z = f(max(L), min(L))
for i in L:
z=f(i,z)
for i in range(1,10**6):
if max(L)>=i and i%z==0:
print(i)
exit()
print(z) | N=int(eval(input()))
L=list(map(int,input().split()))
def f(l, s):
return s if l % s == 0 else f(s, l % s)
z = f(max(L), min(L))
for i in L:
z=f(i,z)
ans=10000000000
for i in range(len(L)):
if L[i]%z==0:
pass
elif L[i]%z<ans:
ans=L[i]%z
if ans==10000000000:
... | p03127 |
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
i = 0
while True:
x = a[i+1] % a[i]
if x < a[i]:
a[i+1] = a[i]
a[i] = x
if a[i] == 0:
i += 1
if i == n-1:
break
else:
break
print((a[i]))
| n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
i = 0
while i < n-1:
x = a[i+1] % a[i]
a[i+1] = a[i]
a[i] = x
if a[i] == 0:
i += 1
print((a[i]))
| p03127 |
n = int(eval(input()))
a = list(map(int, input().split()))
a.sort()
i = 0
while i < n-1:
x = a[i+1] % a[i]
a[i+1] = a[i]
a[i] = x
if a[i] == 0:
i += 1
print((a[i]))
| n = int(eval(input()))
a = list(map(int, input().split()))
i = 0
while i < n-1:
x = a[i+1] % a[i]
a[i+1] = a[i]
a[i] = x
if a[i] == 0:
i += 1
print((a[i]))
| p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
x=0
key = min(A)
while x==0:
for i in range(N):
if int(A[i]%key)==0:
A[i]=key
else:
A[i]=A[i]%key
if min(A)==key:
print(key)
break
else:
key = min(A) | N = int(eval(input()))
List = list(map(int, input().split()))
while len(List)!=1:
m = min(List)
List = [e%m for e in List]
List = [e for e in List if e>0]
List.append(m)
print(m) | p03127 |
n = int(eval(input()))
monster = set(map(int,input().split()))
monster = sorted(list(monster))
if len(monster)==1:
print((monster[0]))
exit()
while True:
tmp = int(monster[-1]/monster[-2])
monster[-1]-=monster[-2]*tmp
monster = sorted(monster)
if monster[-2]==0:
print((monster[-1]))
ex... | def gcd(a, b):
while b:
a, b = b, a % b
return a
n = int(eval(input()))
monster = sorted(list(map(int,input().split())))
ans = []
for i in range(n-1):
g = gcd(monster[i], monster[i+1])
ans.append(g)
print((min(ans))) | p03127 |
def gcd(x,y):
while y>0:
x,y = y,x%y
return x
N = int(eval(input()))
A = list(map(int,input().split()))
x = A[0]
for i in range(1,N):
x = gcd(x,A[i])
print(x) | def gcd(x,y):
while y>0:
x,y = y,x%y
return x
N = int(eval(input()))
A = list(map(int,input().split()))
cmin = A[0]
for i in range(1,N):
cmin = gcd(cmin,A[i])
print(cmin) | p03127 |
n = int(eval(input()))
a = list(map(int,input().split()))
a.sort()
for i in range(1,n):
while a[i]%a[0] != 0:
a[0],a[i] = a[i]%a[0],a[0]
else:
ans = a[0]
print(ans) | n = int(eval(input()))
a = list(map(int,input().split()))
for i in range(1,n):
while a[i]%a[0] != 0:
a[0],a[i] = a[i]%a[0],a[0]
else:
ans = a[0]
print(ans)
| p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
# A内の整数値を用いて作られる最小の整数を求めよ、という問題
def gcd(a, b):
"""
自然数a, b の最大公約数を求める
"""
if b == 0:
return a
else:
return gcd(b, a % b)
ans = float('inf')
for i in range(N):
for j in range(i, N):
ans = mi... | N = int(eval(input()))
A = list(map(int, input().split()))
# A内の整数値を用いて作られる最小の整数を求めよ、という問題
def gcd(a, b):
"""
自然数a, b の最大公約数を求める
"""
if b == 0:
return a
else:
return gcd(b, a % b)
ans = gcd(A[0], A[1])
for i in range(1, N):
ans = min(ans, gcd(ans, A[i]))
... | p03127 |
def gcd(a, b):
lower = min(a, b)
bigger = max(a, b)
for i in range(lower, 0, -1):
if a%i==0 and b%i==0:
return i
def solve():
N = int(eval(input()))
A = [int(x) for x in input().split(" ")]
d = 10**9
for i in range(1, N):
d = min(gcd(A[0], A[i... | def gcd(a, b):
""" 最大公約数。aはbより大きいこと """
if b == 0:
return a
else:
return gcd(b, a%b)
def solve():
N = int(eval(input()))
A = [int(x) for x in input().split(" ")]
A.sort(reverse=True)
ans = A[0]
for i in range(1, N):
ans = gcd(ans, A[i])
pr... | p03127 |
n = int(eval(input()))
mon = list(map(int, input().split()))
g = min(mon)
div = []
for i in range(1, g + 1):
if (g % i == 0):
div.append(i)
div.append(g // i)
if (i * i > g):
break
div.sort(reverse=True)
for d in div:
mod = []
for m in mon:
mod.append(m % d)
if (list(set(mod)) =... | def gcd(x, y):
while(y):
x, y = y, x % y
return x
n = int(eval(input()))
mon = list(map(int, input().split()))
g = mon[0]
for i in range(1, n):
g = gcd(g, mon[i])
print(g) | p03127 |
N = int(eval(input()))
A = list(map(int, input().split()))
sort = sorted(A)
amari = []
while len(amari) != 1:
amari.clear()
if 0 in sort: sort.remove(0)
for item in sort:
if item%sort[0] not in amari:
amari.append(item%sort[0])
last_sort0 = sort[0]
sort = sorted(amari[:])
sort.append(l... | N = int(eval(input()))
A = list(map(int, input().split()))
sort = sorted(A)
# amari = []
# while len(amari) != 1:
# amari.clear()
# if 0 in sort: sort.remove(0)
# for item in sort:
# if item%sort[0] not in amari:
# amari.append(item%sort[0])
# last_sort0 = sort[0]
# sort = sorted(amari[:]... | p03127 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.