s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s752272922 | p02550 | u934119021 | 1600636342 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9620 | 380 | n, x, m = map(int, input().split())
ans = 0
a = x
arr = []
for i in range(n):
if a in arr:
break
else:
arr.append(a)
a = a ** 2 % m
f = sum(arr[:arr.index(a)])
r = sum(arr[arr.index(a):])
k = (n - arr.index(a)) // (len(arr) - arr.index(a))
b = sum(arr[arr.index(a): arr.index(a) + (n - (arr.index(a) + (len... |
s489741069 | p02550 | u576432509 | 1600635874 | Python | PyPy3 (7.3.0) | py | Runtime Error | 749 | 74512 | 1107 | n,x,m=map(int,input().split())
if x==0:
print(0)
elif x==1:
print(n)
elif m==1:
print(0)
elif n<=m*2:
asum=x
ai=x
for i in range(1,n):
ai=(ai*ai)%m
asum+=ai
print(asum)
else:
aa=[]
ai=x
icnt=0
asum=0
while not ai in aa:
asum+=ai
aa.ap... |
s123348365 | p02550 | u325282913 | 1600634362 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 74944 | 906 | N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
if X == 1:
print(N)
exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
A = (A**2)%M
if check[A] != 0:
last_count = sum(check)
target_value = A
break
check[A] += 1
A2 = X
first_count = ... |
s920005840 | p02550 | u325282913 | 1600634211 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 75428 | 871 | N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
A = (A**2)%M
if check[A] != 0:
last_count = sum(check)
target_value = A
break
check[A] += 1
A2 = X
first_count = 0
while True:
first_count += 1
... |
s069245351 | p02550 | u325282913 | 1600634178 | Python | PyPy3 (7.3.0) | py | Runtime Error | 83 | 75536 | 919 | N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
A = (A**2)%M
if check[A] != 0:
last_count = sum(check)
target_value = A
break
check[A] += 1
A2 = X
first_count = 0
while True:
first_count += 1
... |
s816328181 | p02550 | u325282913 | 1600633076 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 75244 | 808 | N, X, M = map(int, input().split())
check = [0]*(M+1)
check[X] += 1
A = X
last_count = 0
while True:
A = (A**2)%M
if check[A] != 0:
last_count = sum(check)
target_value = A
break
check[A] += 1
A2 = X
first_count = 0
while True:
first_count += 1
A2 = (A2**2)%M
if A2 == tar... |
s183791731 | p02550 | u970449052 | 1600632413 | Python | Python (3.8.2) | py | Runtime Error | 80 | 13324 | 339 | N, X, M = map(int, input().split())
if X == 0:
print(0)
exit()
tx = X % M
tl = []
ts = set()
ttl = []
for i in range(N):
tl.append(tx)
ts.add(tx)
tx = pow(tx, 2, M)
if tx in ts:
ttl = tl[tl.index(tx):]
break
ans = sum(tl)
d, m = divmod(N-len(tl), len(ttl))
ans += sum(ttl)*d+sum(t... |
s108310231 | p02550 | u970449052 | 1600632384 | Python | Python (3.8.2) | py | Runtime Error | 78 | 13468 | 328 | N, X, M = map(int, input().split())
if X == 0:
print(0)
tx = X % M
tl = []
ts = set()
ttl = []
for i in range(N):
tl.append(tx)
ts.add(tx)
tx = pow(tx, 2, M)
if tx in ts:
ttl = tl[tl.index(tx):]
break
ans = sum(tl)
d, m = divmod(N-len(tl), len(ttl))
ans += sum(ttl)*d+sum(ttl[:m])
pri... |
s253553515 | p02550 | u970449052 | 1600632260 | Python | Python (3.8.2) | py | Runtime Error | 79 | 13280 | 304 | N, X, M = map(int, input().split())
tx = X % M
tl = []
ts = set()
ttl = []
for i in range(N):
tl.append(tx)
ts.add(tx)
tx = pow(tx, 2, M)
if tx in ts:
ttl = tl[tl.index(tx):]
break
ans = sum(tl)
d, m = divmod(N-len(tl), len(ttl))
ans += sum(ttl)*d+sum(ttl[:m])
print(ans)
|
s209752973 | p02550 | u970449052 | 1600631940 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9712 | 278 | N, X, M = map(int, input().split())
tx = X % M
tl = []
ttl = []
for i in range(N):
tl.append(tx)
tx = pow(tx, 2, M)
if tx in tl:
ttl = tl[tl.index(tx):]
break
ans = sum(tl)
d, m = divmod(N-len(tl), len(ttl))
ans += sum(ttl)*d+sum(ttl[:m])
print(ans)
|
s035747234 | p02550 | u325282913 | 1600627984 | Python | PyPy3 (7.3.0) | py | Runtime Error | 87 | 75132 | 791 | N, X, M = map(int, input().split())
check = [0]*(M+1)
check[X] += 1
A = X
while True:
A = (A**2)%M
if check[A] != 0:
last_count = sum(check)
target_value = A
break
check[A] += 1
A2 = X
first_count = 0
while True:
first_count += 1
A2 = (A2**2)%M
if A2 == target_value:
... |
s893194628 | p02550 | u576432509 | 1600622370 | Python | PyPy3 (7.3.0) | py | Runtime Error | 751 | 74712 | 767 |
n,x,m=map(int,input().split())
if x==0:
print(0)
elif m==1:
print(0)
elif n<=m*3:
asum=x
ai=x
for i in range(1,n):
ai=(ai*ai)%m
asum+=ai
print(asum)
else:
aa=[]
ai=x
icnt=0
asum=0
while not ai in aa:
asum+=ai
aa.append(ai)
ai=(ai... |
s494711244 | p02550 | u576432509 | 1600622161 | Python | PyPy3 (7.3.0) | py | Runtime Error | 753 | 74724 | 743 |
n,x,m=map(int,input().split())
if x==0:
print(0)
elif n<=m*3:
asum=x
ai=x
for i in range(1,n):
ai=(ai*ai)%m
asum+=ai
print(asum)
else:
aa=[]
ai=x
icnt=0
asum=0
while not ai in aa:
asum+=ai
aa.append(ai)
ai=(ai*ai)%m
icnt+=1
... |
s423864748 | p02550 | u576432509 | 1600621950 | Python | PyPy3 (7.3.0) | py | Runtime Error | 754 | 74264 | 719 |
n,x,m=map(int,input().split())
if n<=m*3:
asum=x
ai=x
for i in range(1,n):
ai=(ai*ai)%m
asum+=ai
print(asum)
else:
aa=[]
ai=x
icnt=0
asum=0
while not ai in aa:
asum+=ai
aa.append(ai)
ai=(ai*ai)%m
icnt+=1
asum0=0
ai0=x
... |
s355657467 | p02550 | u350491208 | 1600621916 | Python | Python (3.8.2) | py | Runtime Error | 85 | 16376 | 585 | n, x, m = map(int, input().split())
ida = [-1] * (m + 1)
a = [-1] * (m + 1)
sa = [-1] * (m + 1)
a[1] = x
sa[1] = x
ida[x] = 1
l_len = 1
l_start = 1
for i in range(2, m + 1):
fx = a[i - 1] ** 2 % m
if ida[fx] < 0:
ida[fx] = i
a[i] = fx
sa[i] = sa[i - 1] + a[i]
else:
a[i] = fx
... |
s680446259 | p02550 | u152741807 | 1600621245 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 30164 | 448 | import numpy as np
import sys
n,x,m = (int(i) for i in input().split())
l = np.array([x])
ans = x
memo_array = [-1]*(m+1)
for i in range(1,n):
ans = ans**2%m
idx = memo_array[ans]
if idx != -1:
loop_num, mod = divmod((n-idx),(i-idx))
print(np.sum(l[:loop_start]) + np.sum(l[loop_start:])*(lo... |
s613817804 | p02550 | u152741807 | 1600621073 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 28808 | 494 | import numpy as np
import sys
n,x,m = (int(i) for i in input().split())
l = np.array([x])
ans = x
memo_array = [False]*(m+1)
for i in range(1,n):
ans = ans**2%m
if memo_array[ans]:
loop_start = int(np.where(l==ans)[0])
loop_num, mod = divmod((n-loop_start),(i-loop_start))
print(np.sum(l... |
s250536064 | p02550 | u576432509 | 1600620969 | Python | PyPy3 (7.3.0) | py | Runtime Error | 754 | 74520 | 722 |
n,x,m=map(int,input().split())
if n<=m*3:
asum=x
ai=x
for i in range(1,n):
ai=(ai*ai)%m
asum+=ai
print(asum)
else:
aa=[]
ai=x
icnt=0
asum=0
while not ai in aa:
asum+=ai
aa.append(ai)
ai=(ai*ai)%m
icnt+=1
asum0=0
ai0=x
... |
s705268888 | p02550 | u152741807 | 1600620890 | Python | Python (3.8.2) | py | Runtime Error | 2154 | 28692 | 490 | import numpy as np
import sys
n,x,m = (int(i) for i in input().split())
l = np.array([x])
ans = x
memo_array = [False]*m
for i in range(1,n):
ans = ans**2%m
if memo_array[ans]:
loop_start = int(np.where(l==ans)[0])
loop_num, mod = divmod((n-loop_start),(i-loop_start))
print(np.sum(l[:lo... |
s597012581 | p02550 | u620084012 | 1600617851 | Python | PyPy3 (7.3.0) | py | Runtime Error | 81 | 75236 | 404 | N, X, M = map(int,input().split())
if X == 0:
print(0)
exit(0)
t = X
A = [0]*(M+1)
A[X] = 1
B = [X]
k = 1
while True:
X = (X*X)%M
if X == 0 or k == N:
print(sum(B))
exit(0)
elif A[X] != 0:
s, e = A[X], k
r = k-A[X]
break
else:
A[X] = k
B.ap... |
s691075590 | p02550 | u620084012 | 1600617155 | Python | PyPy3 (7.3.0) | py | Runtime Error | 80 | 75356 | 368 | N, X, M = map(int,input().split())
t = X
A = [0]*(M+1)
A[X] = 1
B = [X]
k = 1
while True:
X = (X*X)%M
if X == 0 or k == N:
print(sum(B))
exit(0)
elif A[X] != 0:
s, e = A[X], k
r = k-A[X]
break
else:
A[X] = k
B.append(X)
k += 1
print(sum(B[:... |
s052150107 | p02550 | u620084012 | 1600617026 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 75464 | 366 | N, X, M = map(int,input().split())
t = X
A = [0]*(M)
A[X] = 1
B = [X]
k = 1
while True:
X = (X*X)%M
if X == 0 or k == N:
print(sum(B))
exit(0)
elif A[X] != 0:
s, e = A[X], k
r = k-A[X]
break
else:
A[X] = k
B.append(X)
k += 1
print(sum(B[:s]... |
s134315321 | p02550 | u620084012 | 1600616595 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 75392 | 347 | N, X, M = map(int,input().split())
t = X
A = [0]*(M)
A[X] = 1
B = [X]
k = 1
while True:
X = (X*X)%M
if X == 0:
print(sum(B))
exit(0)
elif A[X] != 0:
s, e = A[X], k
r = k-A[X]
break
else:
A[X] = k
B.append(X)
k += 1
print(sum(B[:s-2])+(N//r)... |
s949948961 | p02550 | u620084012 | 1600616388 | Python | PyPy3 (7.3.0) | py | Runtime Error | 80 | 75308 | 334 | N, X, M = map(int,input().split())
t = X
A = [0]*(M)
A[X] = 1
B = [X]
k = 1
while True:
X = (X*X)%M
if X == 0:
print(sum(B))
exit(0)
elif A[X] != 0:
s, e = A[X], k
r = k-A[X]
break
else:
A[X] = k
B.append(X)
k += 1
print((N//r)*sum(B[s:e])+... |
s860105895 | p02550 | u545368057 | 1600611790 | Python | Python (3.8.2) | py | Runtime Error | 154 | 14752 | 708 | n,x,m = map(int, input().split())
b = x%m
add = 0
# nがm以下なら全部足せば良い
ans = 0
if n <= m:
for i in range(n):
ans += b
b = pow(b,2,m)
print(ans)
exit()
# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
cnt += 1
# 位数と初期値を出す
s = set()
for i in range(m):
if i < cnt:
add += b
... |
s641064008 | p02550 | u545368057 | 1600611640 | Python | Python (3.8.2) | py | Runtime Error | 154 | 14588 | 665 | n,x,m = map(int, input().split())
b = x%m
add = 0
# nがm以下なら全部足せば良い
ans = 0
if n <= m:
for i in range(n):
ans += b
b = pow(b,2,m)
print(ans)
exit()
# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
cnt += 1
# 位数と初期値を出す
s = set()
for i in range(m):
if i < cnt:
add += b
... |
s457118953 | p02550 | u545368057 | 1600611603 | Python | Python (3.8.2) | py | Runtime Error | 162 | 14732 | 688 | n,x,m = map(int, input().split())
b = x%m
add = 0
# nがm以下なら全部足せば良い
ans = 0
if n <= m:
for i in range(n):
ans += b
b = pow(b,2,m)
print(ans)
exit()
# nがmより大のとき、効率化
cnt = 0
while 2 ** cnt < m:
cnt += 1
# 位数と初期値を出す
s = set()
for i in range(m):
if i < cnt:
add += b
... |
s638170596 | p02550 | u054514819 | 1600611155 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 86804 | 596 | import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)
N, X, mod = mapint()
first = set()
second = set()
in_loop = []
ans = 0
for i in range(min(10**5*2, N)):
if X in first:
if X in second:
break
in_loop.ap... |
s051622869 | p02550 | u288430479 | 1600610422 | Python | Python (3.8.2) | py | Runtime Error | 71 | 11180 | 825 | n,x,m = map(int,input().split())
mod = m
ans = 0
bit = [-1 for i in range(m)]
cycle = False
for i in range(n):
if i == 0 :
a = x
bit[a] = i
ans += a
else:
a = (a**2)% mod
if bit[a] != -1:
cy_st = bit[a]
cy_fi = i -1
cycle = True
... |
s777753093 | p02550 | u893063840 | 1600610371 | Python | Python (3.8.2) | py | Runtime Error | 50 | 15684 | 348 | n, x, m = map(int, input().split())
a = x
li = [a]
exists = dict()
for i in range(2, n + 1):
a = a * a % m
if a in exists:
break
li.append(a)
exists[a] = i
ans = sum(li)
if i != n:
loop, left = divmod(n - i + 1, i - exists[a])
ans += loop * sum(li[exists[a]-1:]) + sum(li[exists[a]-1:ex... |
s839857679 | p02550 | u288430479 | 1600610370 | Python | Python (3.8.2) | py | Runtime Error | 68 | 11344 | 825 | n,x,m = map(int,input().split())
mod = m
ans = 0
bit = [-1 for i in range(m)]
cycle = False
for i in range(n):
if i == 0 :
a = x
bit[a] = i
ans += a
else:
a = (a**2)% mod
if bit[a] != -1:
cy_st = bit[a]
cy_fi = i -1
cycle = True
... |
s408257469 | p02550 | u288430479 | 1600609426 | Python | Python (3.8.2) | py | Runtime Error | 67 | 11204 | 730 | n,x,m = map(int,input().split())
mod = m
ans = 0
bit = [-1 for i in range(m)]
cycle = False
for i in range(n):
if i == 0 :
a = x
bit[a] = i
ans += a
else:
a = (a**2)% mod
if bit[a] != -1:
cy_st = bit[a]
cy_fi = i -1
cycle = True
... |
s410841122 | p02550 | u397953026 | 1600605687 | Python | PyPy3 (7.3.0) | py | Runtime Error | 777 | 78088 | 863 | n,x,m = map(int,input().split())
mod = m
num = []
ans = 0
cnt = 0
ch = x
#ループの始まりを特定
while True:
if ch not in num:
num.append(ch)
else:
st = ch #ループの開始している配列の初めの数字
break
ch *= ch
ch %= mod
#ループの始まりの配列の添え字を特定
for i in range(len(num)):
if num[i] == st:
stnum = i #ループ開... |
s763870115 | p02550 | u137542041 | 1600604817 | Python | Python (3.8.2) | py | Runtime Error | 60 | 15784 | 430 | N, X, M = map(int, input().split())
nxt = X
lst = []
dic = {}
for i in range(M):
if nxt in dic:
loop_st = dic[nxt]
loop_ed = i - 1
break
lst.append(nxt)
dic[nxt] = i
nxt = (nxt ** 2) % M
v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)
pre_sum = sum(lst[:loop_st])
l... |
s323541207 | p02550 | u356567743 | 1600604777 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9092 | 141 | n, x, m = map(int, input().split())
l = []
l[0] = x
ans = x
for i in range(n):
l[i] = (l[i-1]*l[i-1]) % m
ans += l[i]
print(ans)
|
s422199072 | p02550 | u137542041 | 1600604764 | Python | Python (3.8.2) | py | Runtime Error | 58 | 15704 | 394 | N, X, M = map(int, input().split())
nxt = X
lst = []
dic = {}
for i in range(M):
if nxt in dic:
loop_st = dic[nxt]
loop_ed = i - 1
break
lst.append(nxt)
dic[nxt] = i
nxt = (nxt ** 2) % M
v = N - loop_st
q, r = divmod(v, loop_ed - loop_st + 1)
pre_sum = sum(lst[:loop_st])
l... |
s740702970 | p02550 | u015767468 | 1600603619 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 9508 | 354 | N,X,M=list(map(int,input().split()))
C=[]
C.append(X)
for i in range(N):
t=(C[i]**2)%M
if t not in C:
C.append(t)
else:
k=C.index(t)
L=i-k+1
break
Cinitial=C[0:k]
Crepeat=C[k:]
sumCrepeat=sum(Crepeat)
sumCinitial=sum(Cinitial)
S=(N-k)//L
print(sumCinitial+sumCrepeat*S+sum(Cr... |
s775040023 | p02550 | u015767468 | 1600603501 | Python | Python (3.8.2) | py | Runtime Error | 26 | 9056 | 373 | N,X,M=list(map(int,input().split()))
C=[]
C.append(X)
for i in range(M+3):
t=(C[i]**2)%M
if t not in C:
C.append(t)
else:
k=C.index(t)
L=i-k+1
break
Cinitial=C[0:k]
Crepeat=C[k:]
sumCrepeat=sum(C[i] for i in range(k:))
sumCinitial=sum(Cinitial)
S=(N-k)//L
print(sumCinitial+s... |
s964633350 | p02550 | u414050834 | 1600602221 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9636 | 409 | n,x,m=map(int,input().split())
ans=0
p=0
l=[x]
o=0
if x%m==0:
print(x)
else:
for i in range(1,n):
s=(l[i-1]**2)%m
if s==0:
break
if s in l:
p=1
o=list.index(s)
break
else:
l.append(s)
if p==1:
t=sum(l[o:])
k=(n-o)//(len(l)-1) #ループ何回回るか
j=(n-o)%(len(l)... |
s768936512 | p02550 | u414050834 | 1600601805 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 9604 | 418 | n,x,m=map(int,input().split())
ans=0
p=0
l=[x]
if x%m==0:
print(x)
else:
for i in range(1,n):
s=(l[i-1]**2)%m
if s==0:
p=1
break
if s in l:
p=2
break
else:
l.append(s)
if p==2:
t=sum(l[1:])
k=(n-1)//(len(l)-1) #ループ何回回るか
j=(n-1)%(len(l)-1)
ans=x+t*k+sum... |
s721584512 | p02550 | u350491208 | 1600601396 | Python | Python (3.8.2) | py | Runtime Error | 573 | 100976 | 177 | n, x, m = map(int, input().split())
a = [0] * (n+1)
sa = [0] * (n+1)
a[1] = x
sa[1] = x
for i in range(2, n+1):
a[i] = a[i-1]**2 % m
sa[i] = sa[i-1] + a[i]
print(sa[n]) |
s826350184 | p02550 | u061835391 | 1600600356 | Python | Python (3.8.2) | py | Runtime Error | 25 | 9064 | 90 | n,x,m=map(int,input().split())
a=x
for i in range(0,n):
p=(a*a)%m
w=w+p
a=p
print(w) |
s815595962 | p02550 | u056358163 | 1600599543 | Python | Python (3.8.2) | py | Runtime Error | 65 | 15588 | 582 | N, X, M = map(int, input().split())
ans = X
x = X
C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = x**2 % M
if Xd[x] > -1:
break
Xd[x] = i
Xl.append(x)
ans += x
C.append(ans)
# print(Xl)
# print(C)
# print(Xd[x], i)
loop_len = i - Xd[x]
# print(loop_len)
if ... |
s917811753 | p02550 | u056358163 | 1600599503 | Python | Python (3.8.2) | py | Runtime Error | 66 | 15608 | 579 | N, X, M = map(int, input().split())
ans = X
x = X
C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = x**2 % M
if Xd[x] > -1:
break
Xd[x] = i
Xl.append(x)
ans += x
C.append(ans)
# print(Xl)
# print(C)
# print(Xd[x], i)
loop_len = i - Xd[x]
# print(loop_len)
if ... |
s009109144 | p02550 | u056358163 | 1600599440 | Python | Python (3.8.2) | py | Runtime Error | 68 | 15740 | 580 | N, X, M = map(int, input().split())
ans = X
x = X
C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = x**2 % M
if Xd[x] > -1:
break
Xd[x] = i
Xl.append(x)
ans += x
C.append(ans)
# print(Xl)
# print(C)
# print(Xd[x], i)
loop_len = i - Xd[x]
# print(loop_len)
if ... |
s871521650 | p02550 | u056358163 | 1600598847 | Python | Python (3.8.2) | py | Runtime Error | 62 | 15524 | 570 | N, X, M = map(int, input().split())
ans = X
x = X
C = [0, x]
Xd = [-1] * (M+1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = x**2 % M
if Xd[x] > -1:
break
Xd[x] = i
Xl.append(x)
ans += x
C.append(ans)
# print(Xl)
# print(C)
# print(Xd[x], i)
S = C[i] - C[Xd[x]]
# print(S)
loop_len = ... |
s578367967 | p02550 | u056358163 | 1600598199 | Python | Python (3.8.2) | py | Runtime Error | 103 | 20696 | 709 | from collections import defaultdict
N, X, M = map(int, input().split())
if M == 0:
print(X)
exit()
ans = X
x = X
m = []
for i in range(0, M+1):
m.append((i ** 2) % M)
C = [x]
Xd = defaultdict(lambda: -1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = m[x]
if Xd[x] > -1:
# print(i)
... |
s016449747 | p02550 | u056358163 | 1600597778 | Python | Python (3.8.2) | py | Runtime Error | 105 | 20624 | 673 | from collections import defaultdict
N, X, M = map(int, input().split())
ans = X
x = X
m = []
for i in range(0, M+1):
m.append((i ** 2) % M)
C = [x]
Xd = defaultdict(lambda: -1)
Xd[x] = 0
Xl = [x]
for i in range(1, N):
x = m[x]
if Xd[x] > -1:
# print(i)
break
Xd[x] = i
Xl.a... |
s500445845 | p02550 | u179169725 | 1600596820 | Python | PyPy3 (7.3.0) | py | Runtime Error | 86 | 82524 | 2739 | import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline # 文字列読み込む時はこっち
ra = range
enu = enumerate
def exit(*argv, **kwarg):
print(*argv, **kwarg)
sys.exit()
def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開... |
s356620838 | p02550 | u433380437 | 1600595988 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2212 | 219460 | 598 | n,x,m = map(int,input().split())
y=x
A=[]
A.append(y)
cnt=1
su=x
for i in range(n):
y=(y**2)%m
cnt+=1
if y in A:
break
else:
A.append(y)
su+=y
if len(A)==n:
print(su)
else:
c=A.index(y) #周期のはじめ
d=cnt-(c+1) #周期のはじめから次の周期のはじめで個数を求める
e=sum(A[:c])
#周期に入る... |
s095843954 | p02550 | u433380437 | 1600595905 | Python | PyPy3 (7.3.0) | py | Runtime Error | 782 | 77456 | 598 | n,x,m = map(int,input().split())
y=x
A=[]
A.append(y)
cnt=1
su=x
for i in range(n):
y=(y**2)%m
cnt+=1
if y in A:
break
else:
A.append(y)
su+=y
if len(A)==N:
print(su)
else:
c=A.index(y) #周期のはじめ
d=cnt-(c+1) #周期のはじめから次の周期のはじめで個数を求める
e=sum(A[:c])
#周期に入る... |
s493748662 | p02550 | u520276780 | 1600595495 | Python | Python (3.8.2) | py | Runtime Error | 55 | 13648 | 470 | #周期m以下
n,x,m=map(int, input().split())
used = [0]*(m+1)
used_list=[]
pre=x
flag0=False
s=-1;t=-1
for i in range(m+1):
if pre==0:
flag0=True
break
now=(pre*pre)%m
if used[pre]:
s=used[pre]
break
used[pre]=i
used_list.append(pre)
pre=now
l=len(used_list[s:])... |
s181574300 | p02550 | u666550725 | 1600587860 | Python | PyPy3 (7.3.0) | py | Runtime Error | 80 | 79688 | 372 | N, X, M = map(int, input().split())
B = [0 for i in range(M+1)]
C = [0 for i in range(M)]
ans = 0
f = 0
for i in range(1, N+1):
B[i] = B[i-1] + X
if C[X] != 0:
ans += ((N-C[X]+1) // (i-C[X])) * (B[i-1] - B[C[X]-1])
ans += B[C[X] + (N-C[X]+1) % (i-C[X]) - 1]
f = 1
break
else:
C[X] = i
X = (X ... |
s208321025 | p02550 | u666550725 | 1600587443 | Python | PyPy3 (7.3.0) | py | Runtime Error | 85 | 79364 | 364 | N, X, M = map(int, input().split())
B = [0 for i in range(M+1)]
C = [0 for i in range(M)]
ans = 0
f = 0
for i in range(1, N+1):
B[i] = B[i-1] + X
if C[X] != 0:
ans += ((N-C[X]+1) // (i-C[X])) * (B[i-1] - B[C[X]-1])
ans += B[C[X]+(N-C[X]+1)%(i-C[X])-1]
f = 1
break
else:
C[X] = i
X = X * X % M... |
s683264190 | p02550 | u979552932 | 1600586431 | Python | Python (3.8.2) | py | Runtime Error | 688 | 33212 | 588 | import numpy as np
from sys import stdin
import copy
def main():
input = stdin.readline
n, x, m = map(int, input().split())
a = np.array([x], dtype=np.int64)
h = {}
h[x] = 0
t = 0
for i in range(n - 1):
t = a[i] * a[i] % m
if t in h:
break
h[t] = 0
... |
s377543499 | p02550 | u419655514 | 1600585630 | Python | Python (3.8.2) | py | Runtime Error | 64 | 13128 | 1163 | def readInt():
return int(input())
def readList():
return list(map(int,input().split()))
def readMap():
return map(int,input().split())
def readStr():
return input()
inf=float('inf')
mod = 10**9+7
import math
from collections import OrderedDict
def solve(N,X,M):
A=X
ans=A
seen=set()
order_s... |
s001370592 | p02550 | u419655514 | 1600585366 | Python | Python (3.8.2) | py | Runtime Error | 60 | 13028 | 1149 | def readInt():
return int(input())
def readList():
return list(map(int,input().split()))
def readMap():
return map(int,input().split())
def readStr():
return input()
inf=float('inf')
mod = 10**9+7
import math
from collections import OrderedDict
def solve(N,X,M):
A=X
ans=A
seen=set()
order_s... |
s385828984 | p02550 | u769694158 | 1600582446 | Python | PyPy3 (7.3.0) | py | Runtime Error | 93 | 74632 | 539 | n,x,m=list(map(int,input().split()))
if m==1:
print(x)
else:
d=[-1]*(m-1)
j=1
s=x
a=[]
a.append(x)
while j<n:
x=x**2
x%=m
if d[x]!=-1:
break
else:
d[x]=j
s+=x
a.append(s)
j+=1
##print(d[x],j,s,a[d[x]-1])
... |
s098127826 | p02550 | u769694158 | 1600582404 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74580 | 540 | n,x,m=list(map(int,input().split()))
if m==1:
print(x)
else:
d=[-1]*(m-1)
j=1
s=x
a=[]
a.append(x)
while j<n:
x=x**2
x%=m
if d[x]!=-1:
break
else:
d[x]=j
s+=x
a.append(s)
j+=1
##print(d[x],j,s,a[d[x]-1])
... |
s054529586 | p02550 | u769694158 | 1600582166 | Python | PyPy3 (7.3.0) | py | Runtime Error | 97 | 74496 | 531 | n,x,m=list(map(int,input().split()))
if m==1:
print(x)
else:
d=[-1]*(m-1)
j=1
s=x
a=[]
a.append(x)
while j<n:
x=x**2
x%=m
if d[x]!=-1:
break
else:
d[x]=j
s+=x
a.append(s)
j+=1
##print(d[x],j,s,a[d[x]-1])
... |
s236401964 | p02550 | u769694158 | 1600581934 | Python | PyPy3 (7.3.0) | py | Runtime Error | 95 | 73972 | 407 | n,x,m=list(map(int,input().split()))
d=[-1]*(m-1)
j=1
s=x
a=[]
a.append(x)
while j<n:
x=x**2
x%=m
if d[x]!=-1:
break
else:
d[x]=j
s+=x
a.append(s)
j+=1
##print(d[x],j,s,a[d[x]-1])
if j!=d[x]:
s+=(n-j)//(j-d[x])*(s-a[d[x]-1])
#print(s)
if (n-j)%(j-d[x])!=0:
#p... |
s931086772 | p02550 | u769694158 | 1600581852 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 74020 | 382 | n,x,m=list(map(int,input().split()))
d=[-1]*(m-1)
j=1
s=x
a=[]
a.append(x)
while j<n:
x=x**2
x%=m
if d[x]!=-1:
break
else:
d[x]=j
s+=x
a.append(s)
j+=1
##print(d[x],j,s,a[d[x]-1])
s+=(n-j)//(j-d[x])*(s-a[d[x]-1])
#print(s)
if (n-j)%(j-d[x])!=0:
#print((n-d[x]),(j-d[x]... |
s011971046 | p02550 | u287742786 | 1600576281 | Python | PyPy3 (7.3.0) | py | Runtime Error | 2207 | 74620 | 1167 | # -*- coding: utf-8 -*-
def input_int_array():
return map(int, input().split())
def f(x, m):
return x % m
def find_index(a, x, count):
for i in range(count):
ai = a[i]
if ai == x:
return i
return -1
def answer(n, x, m):
a1 = x
ai = a1
loop_start = -1
lo... |
s301449079 | p02550 | u369133448 | 1600576030 | Python | PyPy3 (7.3.0) | py | Runtime Error | 89 | 82900 | 576 | import collections
n,x,m=map(int,input().split())
if n==1:
print(x)
exit()
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
wk=(wk*wk)%m
if not wk in a:
a[wk]=i
else:
start=a[wk]
end=i
break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiin... |
s481427676 | p02550 | u369133448 | 1600575813 | Python | PyPy3 (7.3.0) | py | Runtime Error | 98 | 82960 | 547 | import collections
n,x,m=map(int,input().split())
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
wk=(wk*wk)%m
if not wk in a:
a[wk]=i
else:
start=a[wk]
end=i
break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
koteiwa+=a[i][0]
loop... |
s603281569 | p02550 | u242580186 | 1600575794 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74684 | 1054 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s065984958 | p02550 | u242580186 | 1600575435 | Python | PyPy3 (7.3.0) | py | Runtime Error | 92 | 74668 | 1058 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s249182696 | p02550 | u242580186 | 1600575386 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74156 | 1052 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s088941121 | p02550 | u242580186 | 1600575322 | Python | PyPy3 (7.3.0) | py | Runtime Error | 88 | 74580 | 1046 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s323124042 | p02550 | u369133448 | 1600575046 | Python | Python (3.8.2) | py | Runtime Error | 68 | 18776 | 541 | import collections
n,x,m=map(int,input().split())
start,end,loopcnt=0,0,0
a={x:0}
wk=x
for i in range(1,m):
wk=(wk*wk)%m
if not wk in a:
a[wk]=i
else:
start=a[wk]
end=i
break
a=sorted(a.items(),key=lambda x:x[1])
koteiindex=min(n,start)
koteiwa=0
for i in range(koteiindex):
koteiwa+=a[i][0]
loop... |
s780008769 | p02550 | u242580186 | 1600566921 | Python | Python (3.8.2) | py | Runtime Error | 76 | 16404 | 1009 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s925669277 | p02550 | u242580186 | 1600566894 | Python | PyPy3 (7.3.0) | py | Runtime Error | 90 | 74788 | 1009 | import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
# import decimal
# from decimal import Decimal
# decimal.getcontext().prec = 10
# from heapq import heappush, heappop, heapify
# import math
# from math import gcd
# import itertools as it
# import collections
# from collections import deque
def inp(... |
s886395867 | p02550 | u784022244 | 1600564395 | Python | PyPy3 (7.3.0) | py | Runtime Error | 82 | 79948 | 1070 | N,X,M=map(int, input().split())
from math import log, ceil
ans=0
ini=[0]*M
mod=[0]*M
ini[0]=sum(list(range(1,M)))
Counter=[0]*M
Counter[0]=M-1
for i in range(1,M):
now=i+1
temp=now
count=1
while now**2<M:
now=now**2
temp+=now
count+=1
m=now**2%M
ini[i]=temp
mod[i]... |
s202129303 | p02550 | u238786149 | 1600563877 | Python | PyPy3 (7.3.0) | py | Runtime Error | 102 | 77500 | 498 | n, x, m = map(int, input().split())
if x == 0:
print(0)
sys.exit()
l = [x]
s = {x}
prev = x
for i in range(1, m):
next = prev ** 2
next = next % m
if next in s:
break
s.add(next)
l.append(next)
prev = next
start = l.index(next)
length = i - start
ans = 0
if n < start + length... |
s138469490 | p02550 | u238786149 | 1600563677 | Python | PyPy3 (7.3.0) | py | Runtime Error | 73 | 77176 | 458 | n, x, m = map(int, input().split())
l = [x]
s = {x}
prev = x
for i in range(1, m):
next = prev ** 2
next = next % m
if next in s:
break
s.add(next)
l.append(next)
prev = next
start = l.index(next)
length = i - start
ans = 0
if n < start + length:
ans += sum(l[:n])
else:
ans +=... |
s564600115 | p02550 | u539969758 | 1600558908 | Python | Python (3.8.2) | py | Runtime Error | 68 | 15468 | 567 | N,X,M = map(int,input().split())
ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
for i in range(N-1):
if TF:
A = A**2 % M
if d.get(A) != None:
srt = d[A] + 1
goal = i
TF = False
if TF:
retu.append(A)
... |
s738954290 | p02550 | u682672120 | 1600558244 | Python | PyPy3 (7.3.0) | py | Runtime Error | 82 | 68572 | 475 | value_index = dict()
n, x, m = map(int, input().split())
a = [0] * m
s = [0] * (m + 1)
for i in range(m):
a[i] = x % m
s[i+1] = s[i] + a[i]
if i == n - 1:
print(s[i+1])
quit()
if a[i] in value_index:
break
value_index[a[i]] = i
x = x * x % m
l = value_index... |
s282264241 | p02550 | u432453907 | 1600557611 | Python | Python (3.8.2) | py | Runtime Error | 2205 | 9752 | 408 | N, X, M = map(int, input().split())
A = [X]
for i in range(M-1):
z = A[i]**2 % M
if z not in A:
A.append(z)
else:
break
idx = A.index(z)
before = A[:idx]
cy_sum = sum(A[idx:])
cy_len = len(A[idx:])
cy_cnt = (N-len(before)) // cy_len
mod = A[idx:idx + N - len(before)-cy_len*cy_cnt]
if cy_... |
s083305804 | p02550 | u539969758 | 1600557554 | Python | Python (3.8.2) | py | Runtime Error | 57 | 13996 | 544 | N,X,M = map(int,input().split())
ans = X
A = X
TF = True
srt = 1000000
retu = dict()
retu[X] = 1
loop = X
for i in range(N-1):
if TF:
A = A**2 % M
if retu.get(A) != None:
srt = j
goal = i
TF = False
break
if TF:
retu[A] = 1
loop... |
s004779438 | p02550 | u019685451 | 1600557237 | Python | PyPy3 (7.3.0) | py | Runtime Error | 84 | 74656 | 454 | import math
N, X, M = map(int, input().split())
A = [X]
vis = [-1] * M
vis[X] = 0
for i in range(1, M):
X = X ** 2 % M
if vis[X] != -1:
pref = A[:vis[X]]
cycle = A[vis[X]:]
break
A.append(X)
vis[X] = i
n_full_period = (N - len(pref)) // len(cycle)
suffix_length = N - len(pref)... |
s995893659 | p02550 | u159723084 | 1600556594 | Python | Python (3.8.2) | py | Runtime Error | 53 | 12352 | 407 | # -*- coding: utf-8 -*-
N,X,M=map(int,input().split())
A=[0]*M
A[0]=X
D=[0]*M
s=N
for i in range(1,N):
a=A[i-1]**2%M
if D[a] == 1:
s=A.index(a)
break
else:
A[i]=a
D[a]=1
if s==N:
ans=sum(A)
else:
A=A[:i]
ans=0
l=len(A)-s
ans+=sum(A[:s])
S=sum(... |
s266576924 | p02550 | u159723084 | 1600556537 | Python | Python (3.8.2) | py | Runtime Error | 60 | 12368 | 411 | # -*- coding: utf-8 -*-
N,X,M=map(int,input().split())
A=[0]*M
A[0]=X
D=[0]*M
s=N
for i in range(1,N):
a=A[i-1]**2%M
if D[a] == 1:
s=A.index(a)
break
else:
A[i]=a
D[a]=1
if s==N:
ans=sum(A[:i])
else:
A=A[:i]
ans=0
l=len(A)-s
ans+=sum(A[:s])
S=... |
s614691896 | p02550 | u335406314 | 1600556387 | Python | Python (3.8.2) | py | Runtime Error | 24 | 9196 | 473 | N,X,M=map(int,input().split())
A = [X,]
setA = {A,}
alast=X
flag=False
for i in range(min(N-1,M)):
P=alast**2%M
if P in setA:
flag=True
d = A.index(P)
C=A[d:]
alast=P
break
else:
A.append(P)
setA.add(P)
alast=P
if alast==0:
print(sum(C))
el... |
s601063153 | p02550 | u202560873 | 1600555844 | Python | Python (3.8.2) | py | Runtime Error | 72 | 21276 | 506 | N, X, M = [int(x) for x in input().split()]
A = [0] * (M + 1)
firstApearAt = {i:0 for i in range(M)}
A[1] = X
firstApearAt[X] = 1
l, r = 1, 1
for i in range(2, M + 1):
A[i] = (A[i - 1] * A[i - 1]) % M
if firstApearAt[A[i]] > 0:
r = i
l = firstApearAt[A[i]]
break
firstApearAt[A[i]] ... |
s313054417 | p02550 | u202560873 | 1600555809 | Python | Python (3.8.2) | py | Runtime Error | 42 | 20148 | 503 | N, X, M = [int(x) for x in input().split()]
A = [0] * (M + 1)
firstApearAt = {i:0 for i in range(M)}
A[1] = X
firstApearAt[X] = 1
l, r = 1
for i in range(2, M + 1):
A[i] = (A[i - 1] * A[i - 1]) % M
if firstApearAt[A[i]] > 0:
r = i
l = firstApearAt[A[i]]
break
firstApearAt[A[i]] = i... |
s441628038 | p02550 | u911856499 | 1600555672 | Python | Python (3.8.2) | py | Runtime Error | 95 | 18000 | 802 | import sys
import copy
#import math
#import itertools
#import numpy as np
#import re
def func(x,m):
return x**2%m
N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {0:X}
A = []
A.append(X)
s = X
i = 0
i_stop = i
#i=0は計算したので1から
for i in range(1,N):
A.append(func(A[i-1],M))
if A[i] in myset:
... |
s565240104 | p02550 | u728566015 | 1600555546 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 9624 | 452 | N, X, M = map(int, input().split())
loop_start, n = 0, 0
A = [X]
for i in range(1, N):
tmp = A[-1]**2 % M
if tmp in A:
loop_start = A.index(tmp)
n = i - A.index(tmp)
break
else:
A.append(tmp)
start, loop = A[:loop_start], A[loop_start:]
sum_start = sum(start)
sum_loop = sum(... |
s848618303 | p02550 | u911856499 | 1600555313 | Python | Python (3.8.2) | py | Runtime Error | 89 | 17904 | 769 | import sys
import copy
#import math
#import itertools
#import numpy as np
#import re
def func(x,m):
return x**2%m
N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {0:X}
A = []
A.append(X)
s = X
i = 0
i_stop = i
#i=0は計算したので1から
for i in range(1,N):
A.append(func(A[i-1],M))
if A[i] in myset:
... |
s087289234 | p02550 | u911856499 | 1600555106 | Python | Python (3.8.2) | py | Runtime Error | 101 | 17896 | 776 | import sys
import copy
#import math
#import itertools
#import numpy as np
#import re
def func(x,m):
return x**2%m
N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {0:X}
A = []
A.append(X)
s = X
i = 0
i_stop = i
#i=0は計算したので1から
for i in range(1,N):
A.append(func(A[i-1],M))
if A[i] in myset:
... |
s061351612 | p02550 | u416011173 | 1600555051 | Python | Python (3.8.2) | py | Runtime Error | 28 | 9056 | 639 | # -*- coding: utf-8 -*-
# 標準入力を取得
N, X, M = list(map(int, input().split()))
# 求解処理
def f(x: int, m: int) -> int:
return x**2 % m
A = {X}
loop_start_index = 0
while True:
A_next = f(A[-1], M)
if A_next in A:
loop_start_index = A.index(A_next)
break
else:
A.add(A_next)
loop_l... |
s116627963 | p02550 | u202560873 | 1600555040 | Python | Python (3.8.2) | py | Runtime Error | 71 | 21404 | 490 | N, X, M = [int(x) for x in input().split()]
A = [0] * (M + 1)
firstApearAt = {i:0 for i in range(M)}
A[1] = X
firstApearAt[X] = 1
for i in range(2, M + 1):
A[i] = (A[i - 1] * A[i - 1]) % M
if firstApearAt[A[i]]:
r = i
l = firstApearAt[A[i]]
break
firstApearAt[A[i]] = i
ans = 0
if ... |
s149038663 | p02550 | u911856499 | 1600554409 | Python | Python (3.8.2) | py | Runtime Error | 87 | 17948 | 667 | import sys
import copy
#import math
#import itertools
#import numpy as np
#import re
def func(x,m):
return x**2%m
N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {0:X}
A = []
A.append(X)
s = X
#i=0は計算したので1から
for i in range(1,N):
A.append(func(A[i-1],M))
if A[i] in myset:
i_stop = i
... |
s967007889 | p02550 | u607075479 | 1600554272 | Python | Python (3.8.2) | py | Runtime Error | 59 | 16364 | 1084 | import sys
import math
from collections import defaultdict
from collections import deque
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
def main():
N, X,... |
s093697564 | p02550 | u411203878 | 1600554058 | Python | PyPy3 (7.3.0) | py | Runtime Error | 94 | 74756 | 750 | N,X,M = map(int,input().split())
#全体ループを見る配列
t_loop = [X]
#初回ループを見る配列
f_loop = [X]
#出現回数を見る辞書
memo = {X:1}
#2回目以降のループを見る配列
s_loop = []
while True:
new_val = t_loop[-1]**2%M
t_loop.append(new_val)
if new_val not in f_memo:
memo[new_val] = 1
f_loop.append(new_val)
else:
memo[new_va... |
s835317843 | p02550 | u469254913 | 1600553923 | Python | Python (3.8.2) | py | Runtime Error | 71 | 16108 | 1453 | # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
def main():
N,X,M = map(int,input().split())
A = [-1 for i in range(M)]
A[0] = X
start = -1
end = -1
cnt = [0 for i in range(M)]
cnt[X] =... |
s981586716 | p02550 | u469254913 | 1600553048 | Python | Python (3.8.2) | py | Runtime Error | 65 | 16120 | 1310 | # import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
def main():
N,X,M = map(int,input().split())
A = [-1 for i in range(M)]
A[0] = X
start = N
end = N
cnt = [0 for i in range(M)]
cnt[X] = 0... |
s281803898 | p02550 | u935511247 | 1600552374 | Python | Python (3.8.2) | py | Runtime Error | 2206 | 13016 | 658 | #import sys
#print(sys.maxsize)
N,X,M=map(int,input().split())
table=list(range(M))
for i in range(M):
table[i]=((table[i]%M)**2)%M
print(table[471])
start=X%M
rireki=list()
rireki.append(start)
ss=0
for j in range(1,N):
if table[start] in rireki:
ss=rireki.index(table[start])
break
else:
... |
s909591120 | p02550 | u202560873 | 1600552175 | Python | Python (3.8.2) | py | Runtime Error | 77 | 21348 | 476 | N, X, M = [int(x) for x in input().split()]
A = [0] * (M + 1)
firstApearAt = {i:0 for i in range(M)}
A[1] = X
for i in range(2, M + 1):
A[i] = (A[i - 1] * A[i - 1]) % M
if firstApearAt[A[i]]:
r = i
l = firstApearAt[A[i]]
break
firstApearAt[A[i]] = i
S = sum(A[l:r])
ans = 0
if N <=... |
s301985998 | p02550 | u805332733 | 1600552136 | Python | PyPy3 (7.3.0) | py | Runtime Error | 81 | 75400 | 707 | def resolve():
N, X, M = map(int, input().split(" "))
checked = [False] * M
val = X
ans = val
val_list = [val]
checked[val] = val
base = M
for i in range(N-1):
val*=val
if val >= base:
val %= base
if checked[val] != False:
loop_start_index = checked[val]+1
loop_val = sum... |
s621886069 | p02550 | u811817592 | 1600551081 | Python | Python (3.8.2) | py | Runtime Error | 27 | 9228 | 402 | n,x,m=map(int,input().split())
a=[]
mod_check_list = [False for _ in range(M)]
a.append(x*x%m)
ind=0
s=0
for i in range(m):
t=a[i]*a[i]%m
if mod_check_list[t]:
ind=a.index(t)
break
mod_check_list[t] = True
a.append(t)
s=sum(a[ind:])
l=len(a)-ind
loop_times = (n-1-ind)//l
answer=loop_time... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.