s_id
string
p_id
string
u_id
string
date
string
language
string
original_language
string
filename_ext
string
status
string
cpu_time
string
memory
string
code_size
string
code
string
error
string
stdout
string
s636868936
p04014
u483645888
1550089035
Python
Python (3.4.3)
py
Runtime Error
576
3952
426
n = int(input()) s = int(input()) flag = False if s == n: print(n+1) exit() def chk(b, n): if n//b == 0: return n else: return chk(b,n//b) + n%b for b in range(2, int(n**0.5)+1): if chk(b, n) == s: print(chk(b,n)) print(b) flag = True exit() for i in range(int(n**0.5), 0, -1): b = (n-s)//i + 1 if chk(b, n) == s: print(b) flag = True break if flag == False: print(-1)
Traceback (most recent call last): File "/tmp/tmp_ti7vy3t/tmpol90sa7c.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s336635958
p04014
u483645888
1550088927
Python
Python (3.4.3)
py
Runtime Error
580
3948
405
n = int(input()) s = int(input()) flag = False if s == n: print(n+1) exit() def chk(b, n): if n//b == 0: return n else: return chk(b,n//b) + n%b for b in range(2, int(n**0.5)+1): if chk(b, n) == s: print(b) flag = True break for i in range(int(n**0.5), 0, -1): b = (n-s)//i + 1 if chk(b, n) == s: print(b) flag = True break if flag == False: print(-1)
Traceback (most recent call last): File "/tmp/tmpsc1qmq4a/tmpvvyftvp5.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s304920502
p04014
u077337864
1548074774
Python
Python (3.4.3)
py
Runtime Error
492
3968
515
import math n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + n%b if n == s: print(n+1) elif n < s: print(-1) else: is_exist = False for i in range(2, int(math.sqrt(n))+1): if f(i, n) == s: print(i) is_exist = True break if not is_exist: for i in range(1, int(math.sqrt(n))+1): b = int((n - s) / i) + 1 if f(b, n) == s: print(b) is_exist = True break if not is_exist: print(-1)
Traceback (most recent call last): File "/tmp/tmpmh5f_l_0/tmp_1y4al_n.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s537601882
p04014
u075012704
1547825746
Python
Python (3.4.3)
py
Runtime Error
2108
69016
823
N = int(input()) S = int(input()) # コーナーケース if N == S: print(N + 1) exit() # x進数 def encode_x_base(n, x): ret = [] while n: ret.append(n % x) n //= x return ret[::-1] # 桁和 def digit_sum(n): if isinstance(n, (int, str)): return sum([int(d) for d in str(n)]) if isinstance(n, list): return sum([int(d) for d in n]) # Bが小さいとき for b in range(2, int(N ** 0.5) + 1): encoded_N = encode_x_base(N, b) d_sum = digit_sum(encoded_N) if d_sum == S: print(b) exit() # Bが大きいときはpを全探索 for p in range(1, int(N ** 0.5) + 1): b = (N - S) // p + 1 encoded_N = encode_x_base(N, b) d_sum = digit_sum(encoded_N) if d_sum == S: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmp5oxm4o7r/tmpw3vz0wio.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s560590048
p04014
u171366497
1547700043
Python
Python (3.4.3)
py
Runtime Error
1285
3948
542
n=int(input()) s=int(input()) rootn=0 while rootn**2<=n: rootn+=1 def fun(b,n): b=int(b) n=int(n) if n<b:return n elif n>=b: return fun(b,n//b)+n%b def main(n,s): if n==s:return n+1 for b in range(2,rootn): if fun(b,n)==s:return int(b) for p in reversed(range(1,rootn)): b=1+(n-s)//p if fun(b,n)==s:return int(b) b=2+(n-s)//p if fun(b,n)==s:return int(b) return -1 x=main(n,s) print(x) #http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
Traceback (most recent call last): File "/tmp/tmpqbrnmegv/tmpftfjf0dc.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s454442628
p04014
u171366497
1547699892
Python
Python (3.4.3)
py
Runtime Error
784
3940
516
n=int(input()) s=int(input()) rootn=0 while rootn**2<=n: rootn+=1 def fun(b,n): if n<b:return n elif n>=b: return fun(b,n//b)+n%b def main(n,s): if n==s:return n+1 for b in range(2,rootn): if fun(b,n)==s:return int(b) for p in reversed(range(1,rootn)): b=1+(n-s)//p if fun(b,n)==s:return int(b) b=2+(n-s)//p if fun(b,n)==s:return int(b) return -1 x=main(n,s) print(x) #http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
Traceback (most recent call last): File "/tmp/tmp7i_7f_f_/tmp1xp9gnug.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s752170213
p04014
u171366497
1547699524
Python
Python (3.4.3)
py
Runtime Error
404
3936
478
n=int(input()) s=int(input()) rootn=0 while rootn**2<=n: rootn+=1 def fun(b,n): if n<b:return n elif n>=b: return fun(b,n//b)+n%b def main(n,s): if n==s:return n+1 for b in range(2,rootn): if fun(b,n)==s:return int(b) for p in range(1,rootn): if (n-s)%p==0: b=1+(n-s)/p if fun(b,n)==s:return int(b) return -1 x=main(n,s) print(x) #http://arc060.contest.atcoder.jp/data/arc/060/editorial.pdf
Traceback (most recent call last): File "/tmp/tmpvv8a_fox/tmpjfvvgs3k.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s573697302
p04014
u281303342
1546660394
Python
Python (3.4.3)
py
Runtime Error
600
3948
434
N = int(input()) S = int(input()) def f(b,n): if n//b==0: return n else: return n%b + f(b,n//b) ans = -1 if S==N: ans = N+1 else: for b in range(2,int(N**.5)+1): if f(b,N)==S: ans = b break if ans == -1: for i in range(int(N**.5)+1,0,-1): b = (N-S)//i + 1 if b>0: if f(b,N)==S: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmpax2fe6j_/tmpdmngqrhh.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s590513604
p04014
u281303342
1546660198
Python
Python (3.4.3)
py
Runtime Error
592
4012
419
N = int(input()) S = int(input()) def f(b,n): if n//b==0: return n else: return n%b + f(b,n//b) ans = -1 if S==N: ans = N+1 else: for b in range(2,int(N**.5)+1): if f(b,N)==S: ans = b break for i in range(int(N**.5)+1,0,-1): b = (N-S)//i + 1 if b>0: if f(b,N)==S: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmpn2kj292x/tmpbk_m35ra.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s182827919
p04014
u281303342
1546659873
Python
Python (3.4.3)
py
Runtime Error
570
3948
391
N = int(input()) S = int(input()) def f(b,n): if n//b==0: return n else: return n%b + f(b,n//b) ans = -1 if S==N: ans = N+1 else: for b in range(2,int(N**.5)+1): if f(b,N)==S: ans = b break for i in range(int(N**.5)+1,0,-1): b = (N-S)//i + 1 if f(b,N)==S: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmpkq_ycqr4/tmp00r0xd67.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s024631396
p04014
u064246852
1546570602
Python
Python (3.4.3)
py
Runtime Error
435
3064
641
import math as m def f(b,n): ans = 0 while n > 0: ans += n % b n = m.floor(n/b) return ans n = int(input()) s = int(input()) if n == s: print(n+1) else: found = False for b in range(2,m.floor(m.sqrt(n))+1): if f(b,n) == s: print(b) found = True break if found == False: for p in range(m.floor(m.sqrt(n)),0,-1): if (n-s) % p == 0: b = (n-s)//p + 1 if f(b,n) == s: print(b) found = True break if found == False: print(-1)
Traceback (most recent call last): File "/tmp/tmptjy6lul5/tmpj6br3813.py", line 9, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s029833831
p04014
u064246852
1546570168
Python
Python (3.4.3)
py
Runtime Error
387
3936
635
import math as m def f(b,n): if b > n: return n else: return f(b,m.floor(n/b)) + (n % b) n = int(input()) s = int(input()) if n == s: print(n+1) else: found = False for b in range(2,m.floor(m.sqrt(n))+1): if f(b,n) == s: print(b) found = True break if found == False: for p in range(m.floor(m.sqrt(n)),0,-1): if (n-s) % p == 0: b = (n-s)//p + 1 if f(b,n) == s: print(b) found = True break if found == False: print(-1)
Traceback (most recent call last): File "/tmp/tmpg7vchc3r/tmpk9ib_mf1.py", line 8, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s681307633
p04014
u604896914
1541965533
Python
Python (3.4.3)
py
Runtime Error
240
3064
599
import math def gcd(a,b): """Compute the greatest common divisor of a and b""" while b > 0: a, b = b, a % b return a def lcm(a, b): """Compute the lowest common multiple of a and b""" return a * b / gcd(a, b) def f(b,n): if n < b: return n return f(b, n//b) + n%b N = int(input()) S = int(input()) if N == S: print(N+1) exit() if N < S: print(-1) exit() for B in range(2, int(math.sqrt(N))+1): if(f(B,N)==S): print(B) exit() for p in range(0,int(math.sqrt(N))): B = (N-S)/p + 1 if(B==int(B) and f(int(B),N)==S): print(B) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpvz7lm4p8/tmpr2y0bxls.py", line 19, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s747907243
p04014
u214617707
1541249933
Python
PyPy3 (2.4.0)
py
Runtime Error
2106
40796
435
N = int(input()) S = int(input()) def f(b, n): s = 0 while n > 0: s += n % b n //= b return s num = -1 for i in range(2, int(N ** 0.5) + 1): if f(i, N) == S: num = i break if num == -1: for i in range(int(N ** 0.5) + 1, 0, -1): if (N - S) % i == 0: b = (N - S) // i + 1 if f(b, N) == S: num = b break print(num)
Traceback (most recent call last): File "/tmp/tmp168gqddo/tmpach25x6u.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s124405247
p04014
u214617707
1541249680
Python
Python (3.4.3)
py
Runtime Error
2103
3188
430
N = int(input()) S = int(input()) def f(b, n): s = 0 while n > 0: s += n % b n //= b return s num = -1 for i in range(2, int(N ** 0.5) + 1): if f(i, N) == S: num = i break if num == -1: for i in range(1, int(N ** 0.5) + 1): if (N - S) % i == 0: b = (N - S) // i + 1 if f(b, N) == S: num = b break print(num)
Traceback (most recent call last): File "/tmp/tmp_pmyxztn/tmpm9wfwdsq.py", line 1, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s691200715
p04014
u170201762
1541154390
Python
Python (3.4.3)
py
Runtime Error
17
2940
561
rom math import floor,ceil def f(b,n): if n < b: return n else: return f(b,floor(n/b))+n%b n = int(input()) s = int(input()) for b in range(2,320000): if f(b,n)==s: print(b) exit() if n==s: print(s+1) exit() d = {} for i in range(1,ceil(n**0.5)): m = f(n//i,n) if n//i==n//(i+1): d[i] = (m,m) else: M = f(n//(i+1)+1,n) d[i] = (m,M) for i in range(ceil(n**0.5)-1,0,-1): m,M = d[i] if m<=s<=M and (s-m)%i==0: print(n//i-(s-m)//i) exit() print(-1)
File "/tmp/tmpd36xnprt/tmp1jt_osqx.py", line 1 rom math import floor,ceil ^^^^ SyntaxError: invalid syntax
s958508415
p04014
u883048396
1539360622
Python
Python (3.4.3)
py
Runtime Error
18
3064
1178
def f(b,n): if n<b: return n return f(b,n//b) + n % b if n < s or (n // 2)+1 < s < n : print("-1") elif s == n: print(n+1) elif s == n//2 +1: if n % 2 == 1: print(n//2 + 1) else: print("-1") elif (n//3) + 2 < s <= n//2: print(n-s+1) elif s == 1: def check(n,b): if n == 1: return b else: if n % b !=0 : return 0 else: return check(n // b,b) for b in range(2,rtn): r = check(n,b) if r: print(r) exit() print(n) else: x = n // s if s - (n //(x+1)) <= x: x = x + 1 if 5 < n/(x -1) - n/x : for b in range(n//x, n//(x-1)): if f(b,n) == s: print(b) exit() for i in range(x-1,2,-1): for b in range(n//i + (n//x)//(n//i), n//i + (n//x)//(n//i) + (2*n//x - n//(x+1))//(x-i)): if f(b,n) == s: print(b) exit() else: for b in range(2,(n//3)+3): if f(b,n) == s: print(b) exit() print(n-s+1)
Traceback (most recent call last): File "/tmp/tmpd3ob1dr2/tmppw6rc4cv.py", line 7, in <module> if n < s or (n // 2)+1 < s < n : ^ NameError: name 'n' is not defined
s335923178
p04014
u883048396
1539342304
Python
Python (3.4.3)
py
Runtime Error
2104
3188
914
n = int(input()) s = int(input()) def f(b,n) : r = 0 i = 1 while n: j = n % b r += j n = (n-j)//b return r if n < s or (n // 2)+1 < s < n : print("-1") elif (n//3) + 2 < s < n//2: print(n-s+1) elif s == n: print(n+1) elif s == 1: def check(n,b): while 1 < n : if n % b != 0: break n //= b if n == 1: return b return 0 for b in range(2,int(n**0.5)+2): r = check(n,b) if r: print(r) exit() print(n) else: x = n // s xd = n % s if s - xd < x: x = x + 1 if 3 < n/(x -1) - n/x : for b in range(n//(x-1),(n//x)+1): if f(b,n) == s: print(b) exit() for b in range(2,(n//2)+2): if f(b,n) == s: print(b) exit() print(n-s+1)
Traceback (most recent call last): File "/tmp/tmpz7bsx3t1/tmp852s8hb9.py", line 1, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s394731591
p04014
u596276291
1538522481
Python
Python (3.4.3)
py
Runtime Error
263
4076
1332
from collections import defaultdict, Counter from itertools import product, groupby, count, permutations, combinations from math import pi, sqrt, floor from collections import deque from bisect import bisect, bisect_left, bisect_right from string import ascii_lowercase from functools import lru_cache import sys sys.setrecursionlimit(10000) INF = float("inf") YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no" dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0] dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1] def inside(y, x, H, W): return 0 <= y < H and 0 <= x < W def ceil(a, b): return (a + b - 1) // b def f(b, n): if n < b: return n return f(b, n // b) + n % b def main(): N = int(input()) S = int(input()) if N < S: print(-1) return ans = INF for b in range(2, int(sqrt(N)) + 1): if f(b, N) == S: ans = min(ans, b) bs = set() t = N - S for i in range(1, int(sqrt(t)) + 5): if t % i == 0: bs.add(i) bs.add(t // i) bs.add(N) bs.add(N + 1) for b in bs: if b == 1: continue if f(b, N) == S: ans = min(ans, b) if ans == INF: print(-1) else: print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmp2e5gofpo/tmpdrc41ug3.py", line 65, in <module> main() File "/tmp/tmp2e5gofpo/tmpdrc41ug3.py", line 31, in main N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s485546120
p04014
u608088992
1537643019
Python
Python (3.4.3)
py
Runtime Error
2104
3316
571
import math n = int(input()) s = int(input()) def f(b, n): ans = 0 while b <= n: ans += n%b n //= b ans += n return ans if n == s: print(n+1) else: for b in range(2, math.ceil(math.sqrt(n)) + 1): if f(b, n) == s: print(b) break else: for p in range(1, math.ceil(math.sqrt(n)) + 1): if s - p >= 0 and n-s+p > 0: b = round((n-s+p)/p, ) if f(b, n) == s: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmpyrez2ins/tmplwwq3u3h.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s956308563
p04014
u608088992
1537640898
Python
Python (3.4.3)
py
Runtime Error
506
3964
510
import math n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + (n%b) if n == s: print(n+1) elif n < s: print(-1) else: for b in range(2, int(math.sqrt(n)) + 1): if f(b, n) == s: print(b) break else: for p in range(1, int(math.sqrt(n)) + 1): b = int(((n-s)/p) + 1) if f(b, n) == s: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmp_1f0eptz/tmp5zo2jryw.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s248757179
p04014
u608088992
1537640055
Python
Python (3.4.3)
py
Runtime Error
498
3956
511
import math n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + (n%b) if n == s: print(n+1) elif n == 1: print(-1) else: for b in range(2, int(math.sqrt(n)) + 1): if f(b, n) == s: print(b) break else: for p in range(1, int(math.sqrt(n)) + 1): b = int(((n-s)/p) + 1) if f(b, n) == s: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmpsta8ljy2/tmp6d9vfnyk.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s358055267
p04014
u608088992
1537639650
Python
Python (3.4.3)
py
Runtime Error
541
3964
528
import math n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + (n%b) if n == s: print(n+1) elif n == 1: print(1 if s == 1 else -1) else: for b in range(2, int(math.sqrt(n)) + 1): if f(b, n) == s: print(b) break else: for p in range(1, int(math.sqrt(n)) + 1): b = int(((n-s)/p) + 1) if f(b, n) == s: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmpiodoto5t/tmprnvuoc4o.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s929824708
p04014
u884982181
1535675972
Python
Python (3.4.3)
py
Runtime Error
2106
57368
446
import math n = int(input()) s = int(input()) if n == s: print(n+1) exit() ru = math.ceil(math.sqrt(n))+1 for i in range(2,ru+1): b = n+0 a = [] while b: a.append(b%i) b//=i kota = sum(a) if s == kota: print(i) exit() for i in range(ru,0,-1): q = s-i if q <0: continue c = (n-q)// i b = n+0 a = [] while b: a.append(b%c) b//=c kota = sum(a) if kota == s: print(c) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpw_c5_dr7/tmprvsz3v2i.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s454414350
p04014
u334712262
1534342514
Python
PyPy3 (2.4.0)
py
Runtime Error
2198
1410924
1534
# -*- coding: utf-8 -*- import bisect import heapq import math import random import sys from pprint import pprint from collections import Counter, defaultdict, deque from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal from functools import lru_cache, reduce from itertools import combinations, combinations_with_replacement, product, permutations from operator import add, mul, sub sys.setrecursionlimit(10000) def read_int(): return int(input()) def read_int_n(): return list(map(int, input().split())) def read_float(): return float(input()) def read_float_n(): return list(map(float, input().split())) def read_str(): return input().strip() def read_str_n(): return list(map(str, input().split())) def error_print(*args): print(*args, file=sys.stderr) def mt(f): import time def wrap(*args, **kwargs): s = time.time() ret = f(*args, **kwargs) e = time.time() error_print(e - s, 'sec') return ret return wrap @mt def slv(N, S): if S == N: return N + 1 def f(b, n): if n < b: return n return f(b, n//b) + n % b for b in range(2, int(math.sqrt(N)) + 1): s = f(b, N) if s == S: return b for p in range(1, int(math.sqrt(N))): b = (N - S + p) // p s = f(b, N) if s == S: return b return -1 def main(): N = read_int() S = read_int() print(slv(N, S)) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpadxsi2el/tmp3897q434.py", line 92, in <module> main() File "/tmp/tmpadxsi2el/tmp3897q434.py", line 85, in main N = read_int() ^^^^^^^^^^ File "/tmp/tmpadxsi2el/tmp3897q434.py", line 19, in read_int return int(input()) ^^^^^^^ EOFError: EOF when reading a line
s707274288
p04014
u099566485
1531511603
Python
Python (3.4.3)
py
Runtime Error
486
3964
424
n=int(input()) s=int(input()) def f(bi,nu): if nu<bi: return nu else: return f(bi,nu//bi)+nu%bi if s==n: ans=n+1 elif n<s: ans=-1 else: for i in range(2,int(n**0.5)+1): if f(i,n)==s: ans=i break else: for i in range(int(n**0.5),0,-1): b=int((n-s)/i)+1 if f(b,n)==s: ans=b print(ans)
Traceback (most recent call last): File "/tmp/tmpqqs1_uc5/tmpxanvf7uy.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s421208548
p04014
u099566485
1531511271
Python
Python (3.4.3)
py
Runtime Error
489
3948
423
n=int(input()) s=int(input()) def f(bi,nu): if nu<bi: return nu else: return f(bi,nu//bi)+nu%bi if s==n: ans=n+1 elif n<s: ans=-1 else: for i in range(2,int(n**0.5)+1): if f(i,n)==s: ans=i break else: for i in range(1,int(n**0.5)+1): b=int((n-s)/i)+1 if f(b,n)==s: ans=b print(ans)
Traceback (most recent call last): File "/tmp/tmpio_87dt7/tmpyyl49u1d.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s019830531
p04014
u099566485
1531509215
Python
Python (3.4.3)
py
Runtime Error
497
3948
429
n=int(input()) s=int(input()) def f(bi,nu): if nu<bi: return nu else: return f(bi,nu//bi)+nu%bi for i in range(2,int(n**0.5)+1): if f(i,n)==s: print(i) break else: for p in range(1,int(n**0.5)+1): b=int((n-s)/p)+1 if f(b,n)==s: print(b) break else: if n==s: print(n+1) else: print(-1)
Traceback (most recent call last): File "/tmp/tmp7wm5t49v/tmpd2xgixyk.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s697846757
p04014
u099566485
1531508841
Python
Python (3.4.3)
py
Runtime Error
489
3944
368
n=int(input()) s=int(input()) def f(bi,nu): if nu<bi: return nu else: return f(bi,nu//bi)+nu%bi for i in range(2,int(n**0.5)): if f(i,n)==s: print(i) break else: for p in range(1,int(n**0.5)): b=int((n-s)/p)+1 if f(b,n)==s: print(b) break else: print(-1)
Traceback (most recent call last): File "/tmp/tmph0w_80_h/tmp099iml9o.py", line 1, in <module> n=int(input()) ^^^^^^^ EOFError: EOF when reading a line
s199149665
p04014
u729707098
1530110987
Python
Python (3.4.3)
py
Runtime Error
381
3928
362
from math import sqrt n = int(input()) s = int(input()) def f(x,y): if y<x: return y else: return f(x,y//x)+(y%x) if s==n: ans = n+1 else: ans = -1 for i in range(2,int(sqrt(n))+1): if f(i,n)==s: ans = i break if ans==-1: for i in range(int(sqrt(n)),0,-1): b = (n-s)/i+1 if b==int(b) and f(int(b),n)==s: ans = int(b) break print(ans)
Traceback (most recent call last): File "/tmp/tmp5boxv13g/tmpyd1i0awm.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s305338468
p04014
u268793453
1527607372
Python
Python (3.4.3)
py
Runtime Error
375
3188
463
import math n = int(input()) s = int(input()) ans = [] def f(b, n): if n < b: return n else: return f(b, n//b) + n % b if n == s: ans.append(n+1) elif s == 1: ans.append(n) else: rootn = int(math.sqrt(n)) for b in range(2, rootn): if s == f(b, n): ans.append(b) break for p in range(1, rootn): b = (n-s)//p + 1 if s == p*b + n%b: ans.append(b) if not ans: ans.append(-1) print(min(ans))
Traceback (most recent call last): File "/tmp/tmpeceu_nwg/tmpbe4phrva.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s093999774
p04014
u268793453
1527606820
Python
Python (3.4.3)
py
Runtime Error
371
3064
421
import math n = int(input()) s = int(input()) ans = -1 def f(b, n): if n < b: return n else: return f(b, n//b) + n % b if n == s: ans = n+1 elif s == 1: ans = n else: rootn = int(math.sqrt(n)) for b in range(2, rootn): if s == f(b, n): ans = b break else: for p in range(1, rootn): b = (n-s)//p + 1 if s == p*b + n%b: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmpb0ax0zad/tmpf5pamjf1.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s632504490
p04014
u268793453
1527606240
Python
Python (3.4.3)
py
Runtime Error
379
3064
405
import math n = int(input()) s = int(input()) ans = -1 def f(b, n): if n < b: return n else: return f(b, n//b) + n % b if n == s: ans = n+1 else: rootn = int(math.sqrt(n)) for b in range(2, rootn): if s == f(b, n): ans = b break else: for p in range(1, rootn): b = (n-s)//p + 1 if s == p*b + n%b: ans = b break print(ans)
Traceback (most recent call last): File "/tmp/tmp8jdwm6gj/tmp1is677jn.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s405532635
p04014
u132434645
1525346582
Python
Python (3.4.3)
py
Runtime Error
654
3064
609
import math n = int(input()) s = int(input()) f = None for i in range(2, math.ceil(math.sqrt(n))): c = 0 k = n while k > 0: c += k % i k //= i if c == s: f = i break if f is None: for i in range(int(math.sqrt(n)), 1, -1): b = n // i k = b while k > 0: c += k % b k //= b if (s - c) % i == 0 and b + (s - c) // i < n // (i + 1): print(i, b, c, s - c) f = b + (s - c) // i break if f is None and s <= n // 2: f = n - s + 1 if f is None: print(-1) else: print(f)
Traceback (most recent call last): File "/tmp/tmpwxjmg9hq/tmpn7afr99l.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s726068211
p04014
u621935300
1521947168
Python
Python (2.7.6)
py
Runtime Error
398
12780
446
import math n=input() s=input() def f(b,n): if n<b: return n elif n>=b: return f(b, math.floor(n/b))+n%b if s==n: print n+1 quit() # 2 <= b <= sqrt(n) n_sqrt=int(math.sqrt(n)) for i in range(2, n_sqrt+1): if f(i,n)==s: print i quit() # sqrt(n) < b <= n # yakusuu l=[] for i in range(1, n_sqrt+1): if (n-s)%i==0: l.append(i) l.append((n-s)/i) for i in l: b=i+1 p=n/b q=n%b if p+q==s: print b quit() print -1
File "/tmp/tmpl4veoou_/tmpurdylp9h.py", line 12 print n+1 ^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s062057844
p04014
u621935300
1521939805
Python
Python (2.7.6)
py
Runtime Error
2952
1568900
241
import math n=input() s=input() def f(b,n): if n<b: return n elif n>=b: return f(b, math.floor(n/b))+n%b if s==1: print n quit() if n==1: print -1 quit() for i in range(2,s+1): if f(i,n)==s: print i quit() else: print -1
File "/tmp/tmp0v3bfs8h/tmpa2d4h2_0.py", line 12 print n ^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s824403044
p04014
u226155577
1517813213
Python
Python (3.4.3)
py
Runtime Error
269
3064
510
# seishin.py from math import sqrt n, s = map(int, open(0).read().split()) # s = n if s == n: print(n+1) exit(0) def f(b, n): res = 0 while n: res += n % b n //= b return res # 2 <= b <= sqrt(n) for b in range(2, int(sqrt(n))+1): if f(b, n) == s: print(b) exit(0) # sqrt(n) <= b <= n for p in range(int(sqrt(n)), 0, -1): if (n - s) % p > 0: continue b = (n - s) // p + 1 if f(b, n) == s: print(b) exit(0) print(-1)
Traceback (most recent call last): File "/tmp/tmpbvc6_js5/tmp_v90jnin.py", line 3, in <module> n, s = map(int, open(0).read().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s467037660
p04014
u952708174
1517171664
Python
Python (3.4.3)
py
Runtime Error
532
4144
588
def d_DigitSum(N, S): if S == N: # f(b,N)=Nを満たすbはN+1が最小 return N + 1 from math import sqrt, floor def f(b, n): if n < b: return n else: return f(b, floor(n / b)) + n % b sq = floor(sqrt(N)) # 2<=b<=√Nまで探索 for b in range(2, sq + 1): if f(b, N) == S: return b # √N<=b<=Nまで探索 for p in range(1, sq): b = (N - S) // p + 1 if f(b, N) == S: return b return -1 N = int(input()) S = int(input()) print(d_DigitSum(N, S))
Traceback (most recent call last): File "/tmp/tmp_909glh5/tmp9oot6qgu.py", line 24, in <module> N = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s755999163
p04014
u343675824
1515945639
Python
Python (3.4.3)
py
Runtime Error
325
3956
481
import math import sys n = int(input()) s = int(input()) def f(b, n): if n == 0: return 0 return f(b, n//b) + n % b if s > n: print(-1) sys.exit(0) sn = math.ceil(math.sqrt(n)) for i in range(2, sn): if f(i, n) == s: print(i) sys.exit(0) for i in range(1, sn): if (n - s) % i == 0: b = (n-s)//i + 1 if f(b + n%b, n) == s: print(b) sys.exit(0) if s == n: print(n+1) else: print(-1)
Traceback (most recent call last): File "/tmp/tmp_nmodz4v/tmpq1firudj.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s199231009
p04014
u343675824
1515945412
Python
Python (3.4.3)
py
Runtime Error
374
3064
477
import math import sys n = int(input()) s = int(input()) def f(b, n): if n == 0: return 0 return f(b, n//b) + n % b if s > n: print(-1) sn = math.ceil(math.sqrt(n)) for i in range(2, sn): if f(i, n) == s: print(i) sys.exit(0) for i in range(1, sn): if (n - s) % i == 0: b = (n-s)//i + 1 if 1 + n % b == s and b + n % b == n: print(b) sys.exit(0) if s == n: print(n) else: print(-1)
Traceback (most recent call last): File "/tmp/tmp1ak2_jmp/tmpko0g6qrt.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s353980047
p04014
u343675824
1515945204
Python
Python (3.4.3)
py
Runtime Error
386
3188
419
import math import sys n = int(input()) s = int(input()) def f(b, n): if n == 0: return 0 return f(b, n//b) + n % b sn = math.ceil(math.sqrt(n)) for i in range(2, sn): if f(i, n) == s: print(i) sys.exit(0) for i in range(1, sn): if (n - s) % i == 0: b = (n-s)//i + 1 if 1 + n % b == s and b + n % b == n: print(b) sys.exit(0) print(-1)
Traceback (most recent call last): File "/tmp/tmpqwsvxcpe/tmppzx0_mnn.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s093384892
p04014
u343675824
1515945070
Python
Python (3.4.3)
py
Runtime Error
383
3064
441
import math import sys n = int(input()) s = int(input()) def f(b, n): if n == 0: return 0 return f(b, n//b) + n % b if s == 1: print(n) sys.exit(0) sn = math.ceil(math.sqrt(n)) for i in range(2, sn): if f(i, n) == s: print(i) sys.exit(0) for i in range(1, sn): if (n - s) % i == 0: b = (n-s)//i + 1 if 1 + n % b == s: print(b) sys.exit(0) print(-1)
Traceback (most recent call last): File "/tmp/tmpsvboo4e3/tmprpx47v26.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s893771717
p04014
u343675824
1515944892
Python
PyPy3 (2.4.0)
py
Runtime Error
233
42608
441
import math import sys n = int(input()) s = int(input()) def f(b, n): if n == 0: return 0 return f(b, n//b) + n % b if s == 1: print(n) sys.exit(0) sn = math.ceil(math.sqrt(n)) for i in range(2, sn): if f(i, n) == s: print(i) sys.exit(0) for i in range(1, sn): if (n - s) % i == 0: b = (n-s)//i + 1 if b + n % b == s: print(b) sys.exit(0) print(-1)
Traceback (most recent call last): File "/tmp/tmp01tkeknx/tmp6kk9gcdm.py", line 3, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s692412657
p04014
u425351967
1508171716
Python
Python (3.4.3)
py
Runtime Error
460
3956
420
from math import sqrt n = int(input()) s = int(input()) if n < s: print(-1) import sys sys.exit() if n == s: print(n+1) import sys sys.exit() def f(b, n): if n < b: return n return f(b, n//b) + (n % b) res = -1 for p in range(int(sqrt(n)), 0, -1): b = (n-s)//p + 1 if f(b, n) == s: res = b break for b in range(2, int(sqrt(n))+2): if f(b, n) == s: res = b break print(res)
Traceback (most recent call last): File "/tmp/tmpjbzok_7p/tmptvxednam.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s085195456
p04014
u425351967
1508171209
Python
Python (3.4.3)
py
Runtime Error
520
3964
418
from math import sqrt n = int(input()) s = int(input()) if n < s: print(-1) import sys sys.exit() if n == s: print(n+1) import sys sys.exit() def f(b, n): if n < b: return n return f(b, n//b) + (n % b) res = -1 for p in range(1, int(sqrt(n))+1): b = (n-s)//p + 1 if f(b, n) == s: res = b break for b in range(2, int(sqrt(n))+1): if f(b, n) == s: res = b break print(res)
Traceback (most recent call last): File "/tmp/tmpae5ez8_n/tmpbjqpwubd.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s699693877
p04014
u425351967
1508165785
Python
Python (3.4.3)
py
Runtime Error
470
3960
368
from math import sqrt n = int(input()) s = int(input()) if n < s: print(-1) import sys sys.exit() def f(b, n): if n < b: return n return f(b, n//b) + (n % b) res = -1 for p in range(1, int(sqrt(n))+1): b = (n-s)//p + 1 if f(b, n) == s: res = b break for b in range(2, int(sqrt(n))+1): if f(b, n) == s: res = b break print(res)
Traceback (most recent call last): File "/tmp/tmp_31cuz3i/tmplrjpgcke.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s065322506
p04014
u765237551
1497580965
Python
Python (3.4.3)
py
Runtime Error
1238
664564
441
import sys import math sys.setrecursionlimit(100000000) n = int(input()) s = int(input()) def f(b, n): if n<b: return n else: return f(b, n//b) + n%b if s > n: print(-1) if s==n: print(s+1) else: for b in range(2, math.ceil(math.sqrt(n))+1): if f(b, n)==s: print(b) break else: if f(n+1-s, n)==s: print(n+1-s) else: print(-1)
Traceback (most recent call last): File "/tmp/tmp4d7r4ncr/tmpu9ys5d4z.py", line 6, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s319289227
p04014
u765237551
1497580587
Python
Python (3.4.3)
py
Runtime Error
1484
689908
417
import sys import math sys.setrecursionlimit(100000000) n = int(input()) s = int(input()) def f(b, n): if n<b: return n else: return f(b, n//b) + n%b if s > n: print(-1) else: for b in range(2, math.ceil(math.sqrt(n))+1): if f(b, n)==s: print(b) break else: if f(n+1-s, n)==s: print(n+1-s) else: print(-1)
Traceback (most recent call last): File "/tmp/tmp5b3qwilk/tmp591uln4o.py", line 6, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s515008641
p04014
u614550445
1485661357
Python
Python (3.4.3)
py
Runtime Error
530
18036
428
import math n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + n%b if n == s: print(n+1) exit() for b in range(2, int(math.sqrt(n))+1): if f(b, n) == s: print(b) exit() for p in list(range(1, min(int(math.sqrt(n))+1, s+1)))[::-1]: q = s - p b = (n - q) // p if f(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpryyt2qz6/tmpv8z2ny1y.py", line 4, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s329102290
p04014
u614550445
1485647639
Python
Python (3.4.3)
py
Runtime Error
24
3064
354
n = int(input()) s = int(input()) def f(b, n): if n < b: return n else: return f(b, n//b) + n%b for b in range(int(math.sqrt(n))): if f(b, n) == s: print(b) exit() for p in range(int(math.sqrt(n))): q = s - p b = (n - q) // p if f(b, n) == s: print(b) exit() print(-1)
Traceback (most recent call last): File "/tmp/tmpn7ojclp2/tmpx3bskt05.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s992649057
p04014
u476127533
1474692069
Python
Python (2.7.6)
py
Runtime Error
16
2568
162
x, y = map(int, raw_input().split()) def sumdigit(b=x, n=y): if n < b: return n else: return sumdigit(b, n//b) + n%b print sumdigit(x, y)
File "/tmp/tmpvbln639x/tmpocayrv46.py", line 8 print sumdigit(x, y) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s237215391
p04014
u476127533
1474689772
Python
Python (2.7.6)
py
Runtime Error
16
2568
162
x, y = map(int, raw_input().split()) def sumdigit(b=x, n=y): if n < b: return n else: return sumdigit(b, n/b ) + n%b print sumdigit(x, y)
File "/tmp/tmpdy1g81oc/tmp_eetvofb.py", line 8 print sumdigit(x, y) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s804976369
p04014
u476127533
1474689309
Python
Python (2.7.6)
py
Runtime Error
16
2568
187
import math x, y = map(int, raw_input().split()) def sumdigit(b=x, n=y): if n < b: return n else: return sumdigit(b, math.floor(n/b)) + n%b print sumdigit(x, y)
File "/tmp/tmpy1msa4_y/tmp9l2rrwry.py", line 11 print sumdigit(x, y) ^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s113815919
p04014
u361243145
1473967695
Python
Python (2.7.6)
py
Runtime Error
583
7692
530
class nnDigitSum: def dfs(self,b,n): if n<b: return n return self.dfs(b,n/b)+n%b def returnMinimumB(self,n,s): i=2 while i*i<=n: if self.dfs(i,n)==s: return i i+=1 cands=[] i=1 while i*i<=n-2: if not (n-s)%i: cands.append((n-s)/i+1) i+=1 cands=sorted(cands) for cand in cands: if self.dfs(cand,n)==s: return cand if n==s: return n+1 elif s==1: return n return -1 if __name__ == "__main__": N = int(raw_input()) s = int(raw_input()) d = nnDigitSum() print d.returnMinimumB(N,s)
File "/tmp/tmpi9itqj6l/tmp_lz_t24l.py", line 28 print d.returnMinimumB(N,s) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
s181592564
p04015
u990726146
1600981108
Python
PyPy3 (7.3.0)
py
Runtime Error
221
121152
375
N, A = map(int, input().split()) x = list(map(int, input().split())) dp = [[[0] * 2500 for i in range(51)] for i in range(51)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(2451): dp[i+1][j+1][k+x[i]] += dp[i][j][k] dp[i+1][j][k] += dp[i][j][k] ans = 0 for i in range(1, N+1): ans += dp[N][i][A*i] print(ans)
Traceback (most recent call last): File "/tmp/tmp_fqwg4kk/tmpsqjpq78r.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s560970992
p04015
u192154323
1599394139
Python
Python (3.8.2)
py
Runtime Error
2208
59820
657
N,ave = map(int,input().split()) card_ls = list(map(int, input().split())) #dp[i+1][n][s] := i番目までのカード(0idx)からn枚使って合計がsとなるパターンの数 dp = [[[0]*(ave*N+1) for _ in range(N+1)] for _ in range(N+1)] dp[1][1][card_ls[0]] = 1 dp[1][0][0] = 1 for i in range(1,N): for n in range(N): for s in range(ave*N+1): # i番目を新しく使う if s+card_ls[i] < ave*N+1: dp[i+1][n+1][s+card_ls[i]] += dp[i][n][s] # i番目を使わない dp[i+1][n][s] += dp[i][n][s] #print(dp) ans = 0 for n in range(1,N+1): ans += dp[N][n][n*ave] print(ans)
Traceback (most recent call last): File "/tmp/tmpz_y01tdi/tmp04oqewlr.py", line 1, in <module> N,ave = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s978078031
p04015
u842170774
1599161371
Python
PyPy3 (7.3.0)
py
Runtime Error
95
75536
328
import bisect N,A=map(int,input().split()) x=[i-A for i in map(int,input().split())] dp=[[0]*(2*N*A+1) for _ in [0]*(N+1)] dp[0][N*A]=1 # dp[n][k]:n番目までの整数でkが作れる場合の数 for n in range(1,N+1): for k in range(-N*A,N*A+1): dp[n][k]+=dp[n-1][k-x[n-1]]+dp[n-1][k] print(dp[N][N*A]-1)
Traceback (most recent call last): File "/tmp/tmp2po48awg/tmp2qi51ae2.py", line 3, in <module> N,A=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s622661593
p04015
u885634168
1596850414
Python
PyPy3 (7.3.0)
py
Runtime Error
97
77216
353
N, K = list(map(int,input().split())) a = list(map(int,input().split())) for i in range(N): a[i] -= K dp = [[0 for _ in range(5020)] for _ in range(N + 5)] dp[0][2500] = 1 for i in range(N): for j in range(5000): if j - a[i] >= 0: dp[i + 1][j] += dp[i][j - a[i]] dp[i + 1][j] += dp[i][j] ans = dp[N][2500] - 1 print(ans)
Traceback (most recent call last): File "/tmp/tmpkgso24t_/tmpl9niqin_.py", line 1, in <module> N, K = list(map(int,input().split())) ^^^^^^^ EOFError: EOF when reading a line
s928278225
p04015
u046158516
1596332376
Python
PyPy3 (7.3.0)
py
Runtime Error
87
74716
310
n,a=map(int,input().split()) x=list(map(int,input().split())) dic={} dic2=dic.copy() for i in range(n): for j in dic: if j+x[i]-a in dic2: dic2[j+x[i]-a]+=dic[j] else: dic2[j+x[i]-a]=dic[j] if x[i]-a in dic: dic2[x[i]-a]+=1 else: dic2[x[i]-a]=1 dic=dic2.copy() print(dic[0])
Traceback (most recent call last): File "/tmp/tmpnv0wf91y/tmplz62r689.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s584052745
p04015
u678167152
1596331842
Python
PyPy3 (7.3.0)
py
Runtime Error
150
115072
424
def solve(): ans = 0 N, A = map(int, input().split()) X = list(map(int, input().split())) x = sum(X) dp = [[[0]*(sum(X)+50) for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 for i in range(N): for j in range(i+1): for k in range(x): dp[i+1][j][k] += dp[i][j][k] dp[i+1][j+1][k+X[i]] += dp[i][j][k] for j in range(1,N+1): ans += dp[-1][j][j*A] return ans print(solve())
Traceback (most recent call last): File "/tmp/tmp3k8w1sol/tmp_49m9_5u.py", line 16, in <module> print(solve()) ^^^^^^^ File "/tmp/tmp3k8w1sol/tmp_49m9_5u.py", line 3, in solve N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s521890998
p04015
u035907840
1595009046
Python
Python (3.8.2)
py
Runtime Error
26
8928
668
N, A = map(int, input().split()) *X, = map(lambda x:int(x)-A, input().split()) M = 2500 dp = [[0]*(2*M+1) for _ in range(N)] dp[0][M] += 1 dp[0][X[0]+M] += 1 for i in range(1,N): for v in range(-M, M+1): dp[i][v+M] += dp[i-1][v+M] if -M<=v-X[i]<=M: dp[i][v+M] += dp[i-1][v-X[i]+M] print(dp[-1][M]-1)N, A = map(int, input().split()) *X, = map(lambda x:int(x)-A, input().split()) M = 2500 dp = [[0]*(2*M+1) for _ in range(N)] dp[0][M] += 1 dp[0][X[0]+M] += 1 for i in range(1,N): for v in range(-M, M+1): dp[i][v+M] += dp[i-1][v+M] if -M<=v-X[i]<=M: dp[i][v+M] += dp[i-1][v-X[i]+M] print(dp[-1][M]-1)
File "/tmp/tmp3t1oiydx/tmptrp047ny.py", line 15 print(dp[-1][M]-1)N, A = map(int, input().split()) ^ SyntaxError: invalid syntax
s591808058
p04015
u941047297
1593454217
Python
Python (3.8.2)
py
Runtime Error
59
9916
625
def main(): n, a = list(map(int, input().split())) X = list(map(lambda x: int(x) - a, input().split())) m = sum([x for x in X if x < 0]) p = sum([x for x in X if x > 0]) if p == m == 0: print(pow(2, n) - 1) exit() dp = [[0] * (p - m + 1) for _ in range(n + 1)] dp[0][1 - m] = 1 for i in range(1, n + 1): for j in range(p - m + 1): if 0 <= j - X[i - 1] < p - m + 1: dp[i][j] = dp[i - 1][j] + dp[i - 1][j - X[i - 1]] else: dp[i][j] = dp[i - 1][j] print(dp[n][1 - m] - 1) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpjtvglm2g/tmpa2vaspk9.py", line 20, in <module> main() File "/tmp/tmpjtvglm2g/tmpa2vaspk9.py", line 2, in main n, a = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s478270417
p04015
u648212584
1589686323
Python
PyPy3 (2.4.0)
py
Runtime Error
176
38388
472
import sys input = sys.stdin.buffer.readline import numpy as np def main(): N,A = map(int,input().split()) x = list(map(int,input().split())) for i in range(N): x[i] -= A base = 50*50 dp = np.zeros(base*2+1,dtype=int) dp[base] = 1 for num in x: if num == 0: use = dp.copy() dp += use elif num > 0: use = dp[:-num].copy() dp[num:] += use else: use = dp[-num:].copy() dp[:num] += use print(dp[base]-1) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmpy1vgh9q4/tmpz1eal_7x.py", line 28, in <module> main() File "/tmp/tmpy1vgh9q4/tmpz1eal_7x.py", line 6, in main N,A = map(int,input().split()) ^^^ ValueError: not enough values to unpack (expected 2, got 0)
s215648288
p04015
u630941334
1588815243
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38256
924
import * as fs from 'fs' function main(input: string) { let lines = input.split('\n'); let tmp = lines[0].split(' '); let N = Number(tmp[0]); let A = Number(tmp[1]); let x = [0]; x = x.concat(lines[1].split(' ').map(Number)); let dp = new Array(N + 1); for (let i = 0; i <= N; ++i) { dp[i] = new Array(N + 1); for (let j = 0; j <= N; ++j) { dp[i][j] = new Array(A * N + 1).fill(0); } } for (let i = 0; i < N; ++i) dp[i][0][0] = 1; for (let i = 1; i <= N; ++i) { for (let j = 1; j <= i; ++j) { for (let k = 1; k <= A * N; ++k) { if (k < x[i]) { dp[i][j][k] = dp[i - 1][j][k]; } else { dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]; } } } } let ans = 0; for (let j = 1; j <= N; ++j) { ans += dp[N][j][j * A]; } console.log(ans); } main(fs.readFileSync('/dev/stdin', 'utf8').toString());
File "/tmp/tmph0fhjom_/tmpel52q82e.py", line 1 import * as fs from 'fs' ^ SyntaxError: invalid syntax
s508712326
p04015
u630941334
1588813932
Python
Python (3.4.3)
py
Runtime Error
332
56436
657
def main(): N, A = map(int, input().split()) x = [0].extend(list(map(int, input().split()))) dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)] for i in range(N + 1): dp[i][0][0] = 1 for i in range(1, N + 1): for j in range(1, i + 1): for k in range(1, N * A + 1): if k < x[k]: dp[i][j][k] = dp[i - 1][j][k] else: dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]] ans = 0 for j in range(1, N + 1): ans += dp[N][j][A * j] print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmps7x690uf/tmp7r4x1guu.py", line 25, in <module> main() File "/tmp/tmps7x690uf/tmp7r4x1guu.py", line 2, in main N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s143253018
p04015
u366541443
1588542681
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38384
383
n,ave = list(map(int, input().split())) a = list(map(int, input().split())) dp = [Zeros(3000,n+1) for k in range(n+1)] dp[0][0][0] = 1 for i in range(n): for j in range(2900): for k in range(n): dp[i+1][j+a[i]][k+1] += dp[i][j][k] dp[i+1][j][k] += dp[i][j][k] ans = 0 for k in range(n): ans+= dp[-1][ave*(k+1)][k+1] print(ans)
Traceback (most recent call last): File "/tmp/tmpcfac70d6/tmp7id8a9_j.py", line 1, in <module> n,ave = list(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s401852214
p04015
u207799478
1587744695
Python
PyPy3 (2.4.0)
py
Runtime Error
303
126556
1127
import itertools import math import string import collections from collections import Counter from collections import deque import sys sys.setrecursionlimit(2*10**5) INF = 2**60 def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n)//(math.factorial(n-r)*math.factorial(r)) def has_duplicates2(seq): seen = [] for item in seq: if not(item in seen): seen.append(item) return len(seq) != len(seen) def divisor(n): divisor = [] for i in range(1, n+1): if n % i == 0: divisor.append(i) return divisor # coordinates dx = [-1, -1, -1, 0, 0, 1, 1, 1] dy = [-1, 0, 1, -1, 1, -1, 0, 1] N, A = map(int, input().split()) x = readints() sum = 0 for i in range(N): sum += x[i] dp = [[[0]*(55) for _ in range(55)] for _ in range(3000)] dp[0][0][0] = 1 for i in range(N): for j in range(N+1): for k in range(N*A): dp[i+1][j][k] += dp[i][j][k] if k >= x[i]: dp[i+1][j+1][k] += dp[i][j][k-x[i]] ans = 0 for j in range(1, N+1): ans += dp[N][j][j*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpv9e2s68u/tmpktjl3mnk.py", line 40, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s173290612
p04015
u207799478
1587744620
Python
PyPy3 (2.4.0)
py
Runtime Error
313
126428
1129
import itertools import math import string import collections from collections import Counter from collections import deque import sys sys.setrecursionlimit(2*10**5) INF = 2**60 def readints(): return list(map(int, input().split())) def nCr(n, r): return math.factorial(n)//(math.factorial(n-r)*math.factorial(r)) def has_duplicates2(seq): seen = [] for item in seq: if not(item in seen): seen.append(item) return len(seq) != len(seen) def divisor(n): divisor = [] for i in range(1, n+1): if n % i == 0: divisor.append(i) return divisor # coordinates dx = [-1, -1, -1, 0, 0, 1, 1, 1] dy = [-1, 0, 1, -1, 1, -1, 0, 1] N, A = map(int, input().split()) x = readints() sum = 0 for i in range(N): sum += x[i] dp = [[[0]*(55) for _ in range(55)] for _ in range(3000)] dp[0][0][0] = 1 for i in range(N): for j in range(N+1): for k in range(sum+2): dp[i+1][j][k] += dp[i][j][k] if k >= x[i]: dp[i+1][j+1][k] += dp[i][j][k-x[i]] ans = 0 for j in range(1, N+1): ans += dp[N][j][j*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpmcpalqng/tmpi3p7_k6w.py", line 40, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s357837859
p04015
u768496010
1585987519
Python
Python (3.4.3)
py
Runtime Error
1212
56564
991
n, a = map(int, input().split()) xlist = list(map(int, input().split())) j = n k = n t = n * a maxv = max(xlist) dp = [[[0 for t in range(t + 1)] for k in range(k + 1)] for j in range(j + 1)] dp[1][0][0] = 1 dp[0][0][0] = 1 # for d in dp: # print(d) # print(dp[1][1][15]) for ji in range(0, j + 1): for ki in range(0, ji + 1): for ti in range(0, ki * maxv + 1): # print('now', ji, ki, ti) if ji == 0 and ki == 0 and ti == 0: # print('branch 1') dp[ji][ki][ti] = 1 elif ji >= 1 and ti < xlist[ji - 1]: dp[ji][ki][ti] = dp[ji - 1][ki][ti] # print('branch 2') elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]: # print('branch 3', ji - 1) dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]] # print(dp[ji][ki][ti]) count = 0 for i in range(1, k + 1): count += dp[j][i][i*a] print(count)
Traceback (most recent call last): File "/tmp/tmpfrqpet1q/tmpxf872h4d.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s000428775
p04015
u768496010
1585987248
Python
Python (3.4.3)
py
Runtime Error
1426
65392
996
n, a = map(int, input().split()) xlist = list(map(int, input().split())) j = n k = n t = n * a maxv = max(xlist) dp = [[[0 for t in range(n*maxv + 1)] for k in range(k + 1)] for j in range(j + 1)] dp[1][0][0] = 1 dp[0][0][0] = 1 # for d in dp: # print(d) # print(dp[1][1][15]) for ji in range(0, j + 1): for ki in range(0, ji + 1): for ti in range(0, ki * maxv + 1): # print('now', ji, ki, ti) if ji == 0 and ki == 0 and ti == 0: # print('branch 1') dp[ji][ki][ti] = 1 elif ji >= 1 and ti < xlist[ji - 1]: dp[ji][ki][ti] = dp[ji - 1][ki][ti] # print('branch 2') elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]: # print('branch 3', ji - 1) dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]] # print(dp[ji][ki][ti]) count = 0 for i in range(1, k + 1): count += dp[j][i][i*a] print(count)
Traceback (most recent call last): File "/tmp/tmp_60eo2up/tmpqggot0cp.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s158959649
p04015
u768496010
1585987114
Python
Python (3.4.3)
py
Runtime Error
1416
65392
996
n, a = map(int, input().split()) xlist = list(map(int, input().split())) j = n k = n t = n * a maxv = max(xlist) dp = [[[0 for t in range(n*maxv + 1)] for k in range(k + 1)] for j in range(j + 1)] dp[1][0][0] = 1 dp[0][0][0] = 1 # for d in dp: # print(d) # print(dp[1][1][15]) for ji in range(1, j + 1): for ki in range(0, ji + 1): for ti in range(0, ki * maxv + 1): # print('now', ji, ki, ti) if ji == 0 and ki == 0 and ti == 0: # print('branch 1') dp[ji][ki][ti] = 1 elif ji >= 1 and ti < xlist[ji - 1]: dp[ji][ki][ti] = dp[ji - 1][ki][ti] # print('branch 2') elif ji >= 1 and ki >= 1 and ti >= xlist[ji - 1]: # print('branch 3', ji - 1) dp[ji][ki][ti] = dp[ji - 1][ki][ti] + dp[ji - 1][ki - 1][ti - xlist[ji - 1]] # print(dp[ji][ki][ti]) count = 0 for i in range(1, k + 1): count += dp[j][i][i*a] print(count)
Traceback (most recent call last): File "/tmp/tmp6f67pohz/tmp0gdvco5i.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s085123934
p04015
u994521204
1584423493
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38328
417
%time n,a=map(int,input().split()) X=list(map(int,input().split())) dp=[[[0]*55 for _ in range(2555)] for _ in range(55)] ans=0 dp[0][0][0]=1 for i in range(n): for j in range(52+50*i): for k in range(n): ni=i+1 nj=j+X[i] nk=k+1 dp[ni][nj][nk]+=dp[i][j][k] dp[ni][j][k]+=dp[i][j][k] ans=0 for i in range(1,n+1): ans+=dp[n][i*a][i] print(ans)
File "/tmp/tmp04yodge_/tmp2snzdr5m.py", line 1 %time ^ SyntaxError: invalid syntax
s834129157
p04015
u994521204
1584423273
Python
PyPy3 (2.4.0)
py
Runtime Error
366
112220
411
n,a=map(int,input().split()) X=list(map(int,input().split())) dp=[[[0]*55 for _ in range(2505)] for _ in range(55)] ans=0 dp[0][0][0]=1 for i in range(n): for j in range(52+50*i): for k in range(n): ni=i+1 nj=j+X[i] nk=k+1 dp[ni][nj][nk]+=dp[i][j][k] dp[ni][j][k]+=dp[i][j][k] ans=0 for i in range(1,n+1): ans+=dp[n][i*a][i] print(ans)
Traceback (most recent call last): File "/tmp/tmp5einecj8/tmp2266hg5k.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s116024715
p04015
u994521204
1584423214
Python
PyPy3 (2.4.0)
py
Runtime Error
337
112220
413
n,a=map(int,input().split()) X=list(map(int,input().split())) dp=[[[0]*55 for _ in range(2505)] for _ in range(55)] ans=0 dp[0][0][0]=1 for i in range(n): for j in range(52+50*i): for k in range(i+1): ni=i+1 nj=j+X[i] nk=k+1 dp[ni][nj][nk]+=dp[i][j][k] dp[ni][j][k]+=dp[i][j][k] ans=0 for i in range(1,n+1): ans+=dp[n][i*a][i] print(ans)
Traceback (most recent call last): File "/tmp/tmp34wdi0di/tmp2no6pjis.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s703205732
p04015
u994521204
1584423152
Python
PyPy3 (2.4.0)
py
Runtime Error
336
106332
413
n,a=map(int,input().split()) X=list(map(int,input().split())) dp=[[[0]*52 for _ in range(2505)] for _ in range(52)] ans=0 dp[0][0][0]=1 for i in range(n): for j in range(52+50*i): for k in range(i+1): ni=i+1 nj=j+X[i] nk=k+1 dp[ni][nj][nk]+=dp[i][j][k] dp[ni][j][k]+=dp[i][j][k] ans=0 for i in range(1,n+1): ans+=dp[n][i*a][i] print(ans)
Traceback (most recent call last): File "/tmp/tmpxtc91pgo/tmp864oo9l7.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s465804286
p04015
u683134447
1580614549
Python
Python (3.4.3)
py
Runtime Error
2104
4468
422
n,a = map(int,input().split()) xl = list(map(int,input().split())) # i個のカードまで使って和がjの組み合わせ dp = [[0 for i in range(50*50+1)] for j in range(51)] dp[0][0] = 1 for i in range(n): for j in range(n, -1, -1): for k in range(50*50+1): if k+xl[i] < 50*50+1: dp[j+1][k+xl[i]] += dp[j][k] ans = 0 for i in range(1,n+1): ans += dp[i][i*a] print(ans)
Traceback (most recent call last): File "/tmp/tmplk78u75y/tmpb40u9ata.py", line 1, in <module> n,a = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s135031574
p04015
u076917070
1578618918
Python
Python (3.4.3)
py
Runtime Error
982
65388
586
import sys input = sys.stdin.readline def main(): N, A = map(int, input().split()) X = list(map(int, input().split())) M = max(X)*N dp = [[[0 for k in range(M+1)] for j in range(N+1)] for i in range(N+1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(M): if dp[i][j][k]: dp[i+1][j][k] += dp[i][j][k] dp[i+1][j+1][k+X[i]] += dp[i][j][k] ans = 0 for j in range(1, N+1): ans += dp[N][j][A*j] print(ans) if __name__ == '__main__': main()
Traceback (most recent call last): File "/tmp/tmpgvgpsq17/tmpcak8iu5u.py", line 25, in <module> main() File "/tmp/tmpgvgpsq17/tmpcak8iu5u.py", line 6, in main N, A = map(int, input().split()) ^^^^ ValueError: not enough values to unpack (expected 2, got 0)
s989860953
p04015
u921773161
1570930074
Python
Python (3.4.3)
py
Runtime Error
2107
54388
781
#%% n, a = map(int, input().split()) x = list(map(int, input().split())) x.insert(0, 0) dp = [[[0] * (max(x)*n+1) for _ in range(n+1)] for _ in range(n+1)] dp[0][0][0] = 1 #print(dp) for i in range(1, n+1): for j in range(0, n+1): for k in range(0, max(x)*n+1): if i == 0: pass else: if j == 0: dp[i][j][k] = dp[i-1][j][k] else: if k < x[i]: dp[i][j][k] = dp[i-1][j][k] else: dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-x[i]] #print(x[i]) ans = 0 i = n for j in range(n+1): ans += dp[i][j][j*a] ans -= 1 print(ans) #for i in range(n+1): # print(dp[i])
Traceback (most recent call last): File "/tmp/tmpqy88p3xz/tmpiwra7pih.py", line 2, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s734032248
p04015
u009348313
1569601916
Python
PyPy3 (2.4.0)
py
Runtime Error
459
104540
435
N,A = map(int,input().split()) X = list(map(int,input().split())) MAXSUM = sum(X)+5 dp = [[[0 for _ in range(MAXSUM)] for _ in range(N+5)] for _ in range(N+5)] for i in range(N): dp[i+1][1][X[i]] += 1 for k in range(N): for j in range(MAXSUM): dp[i+1][k][j] += dp[i][k][j] if X[i]+j < MAXSUM: dp[i+1][k+1][X[i]+j] += dp[i][k][j] #print(dp) ans = 0 for i in range(N): ans += dp[N][i+1][A*(i+1)] print(ans)
Traceback (most recent call last): File "/tmp/tmpxwyvxog6/tmpa8iqvbk4.py", line 1, in <module> N,A = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s915080831
p04015
u711539583
1569591768
Python
Python (3.4.3)
py
Runtime Error
2104
3060
280
import sys sys.setrecursionlimit(10**9) n, a = map(int, input().split()) x = list(map(int, input().split())) def rec(i, j, tmp): if i == n: if tmp / j == a: return 1 else: return 0 return rec(i+1, j+1, tmp + x[i]) + rec(i+1, j, tmp) print(rec(0, 0, 0))
Traceback (most recent call last): File "/tmp/tmpxjq7o3jp/tmpyrtbvzpc.py", line 3, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s593885904
p04015
u520276780
1569444833
Python
PyPy3 (2.4.0)
py
Runtime Error
189
41948
591
n, a = map(int, input().split( )) x = list(map(int, input().split())) #print(*x) for i in range(n): x[i] -= a #print(*x) mx = max(x)*n mn = min(x)*n rng = mx + abs(mn) #print(mx,mn,rng,x[0]) if rng ==0:###3 rng+=1 dp = [[0 for _ in range(rng)] for i in range(n)] dp[0][x[0]] += 1 dp[0][0] += 1 for i in range(1,n): for sm in range(rng): #print(i,sm) dp[i][sm] += dp[i-1][sm] + dp[i-1][(sm-x[i]+rng)%rng]### #print(i,sm,dp[sm][i-1] ,dp[sm-x[i]][i-1]) #for i in range(n): # print(*dp[i]) print(dp[n-1][0]-1)#0枚がカウントされてる
Traceback (most recent call last): File "/tmp/tmpw8wkousk/tmpiueh9j9c.py", line 1, in <module> n, a = map(int, input().split( )) ^^^^^^^ EOFError: EOF when reading a line
s847007504
p04015
u520276780
1569444737
Python
PyPy3 (2.4.0)
py
Runtime Error
191
41948
593
n, a = map(int, input().split( )) x = list(map(int, input().split())) #print(*x) for i in range(n): x[i] -= a #print(*x) mx = max(x)*n mn = min(x)*n rng = mx + abs(mn) #print(mx,mn,rng,x[0]) if rng ==0:###3 rng+=1 dp = [[0 for _ in range(rng+1)] for i in range(n)] dp[0][x[0]] += 1 dp[0][0] += 1 for i in range(1,n): for sm in range(rng): #print(i,sm) dp[i][sm] += dp[i-1][sm] + dp[i-1][(sm-x[i]+rng)%rng]### #print(i,sm,dp[sm][i-1] ,dp[sm-x[i]][i-1]) #for i in range(n): # print(*dp[i]) print(dp[n-1][0]-1)#0枚がカウントされてる
Traceback (most recent call last): File "/tmp/tmpwnu711wl/tmpoml5f7aa.py", line 1, in <module> n, a = map(int, input().split( )) ^^^^^^^ EOFError: EOF when reading a line
s005065942
p04015
u708255304
1569277051
Python
Python (3.4.3)
py
Runtime Error
234
54004
726
N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい X = tuple(map(int, input().split())) # N枚のカードの中身 dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 # 0枚の中から0枚選んで合計が0になる選び方が1通りある for i in range(N): for j in range(N+1): for s in range(50*N+1): if s >= X[i]: # 今見ているのはX[i], これをどうするかで遷移先を変更する dp[i+1][j+1][s] += dp[i][j][s-X[i]] # 追加する余裕がある場合は追加する dp[i+1][j][s] += dp[i][j][s] # 何も追加しない ans = 0 for i in range(1, N+1): ans += dp[N][i][i*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpz8tkwhap/tmpai0lmf8v.py", line 1, in <module> N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい ^^^^^^^ EOFError: EOF when reading a line
s312225897
p04015
u708255304
1569276715
Python
Python (3.4.3)
py
Runtime Error
223
54004
754
N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい X = tuple(map(int, input().split())) # N枚のカードの中身 dp = [[[0]*(50*N+1) for _ in range(N+1)] for _ in range(N+1)] dp[0][0][0] = 1 # 0枚の中から0枚選んで合計が0になる選び方が1通りある for i in range(N): now_card = X[i] for j in range(N+1): for s in range(50*N+1): if s >= now_card: # 今見ているのはX[i], これをどうするかで遷移先を変更する dp[i+1][j+1][s] += dp[i][j][s-now_card] # 追加する余裕がある場合は追加する dp[i+1][j][s] += dp[i][j][s] # 何も追加しない ans = 0 for i in range(1, N+1): ans += dp[N][i][i*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpjzmxcl89/tmpacg1hroa.py", line 1, in <module> N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい ^^^^^^^ EOFError: EOF when reading a line
s603430557
p04015
u708255304
1569276548
Python
Python (3.4.3)
py
Runtime Error
2108
56180
761
N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい X = list(map(int, input().split())) # N枚のカードの中身 dp = [[[0]*(max(X)*N+2) for _ in range(N+2)] for _ in range(N+2)] dp[0][0][0] = 1 # 0枚の中から0枚選んで合計が0になる選び方が1通りある for i in range(N): now_card = X[i] for j in range(N+1): for s in range(max(X)*N+1): if s >= now_card: # 今見ているのはX[i], これをどうするかで遷移先を変更する dp[i+1][j+1][s] += dp[i][j][s-now_card] # 追加する余裕がある場合は追加する dp[i+1][j][s] += dp[i][j][s] # 何も追加しない ans = 0 for i in range(1, N+1): ans += dp[N][i][i*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpyxvmn9si/tmpr60zystz.py", line 1, in <module> N, A = map(int, input().split()) # N枚数のカード, 平均をAにしたい ^^^^^^^ EOFError: EOF when reading a line
s612730428
p04015
u670180528
1568956722
Python
Python (3.4.3)
py
Runtime Error
17
2940
128
n,a,*x=map(int,open(0).read().split());dp={0:1} for i in x: for k,v in dp.items(): dp[i+k-a]=dp.get(i+k-a,0)+v print(dp[0]-1)
Traceback (most recent call last): File "/tmp/tmpr03xqu8w/tmp0lqkmcyx.py", line 1, in <module> n,a,*x=map(int,open(0).read().split());dp={0:1} ^^^^^^ ValueError: not enough values to unpack (expected at least 2, got 0)
s317033414
p04015
u285443936
1568686591
Python
PyPy3 (2.4.0)
py
Runtime Error
347
92636
436
N, A = map(int, input().split()) x= [int(i) for i in input().split()] X = max(x) dp = [[[0]*(X*N+1) for i in range(N+1)] for j in range(N+1)] dp[0][0][0] = 1 ans = 0 for j in range(1,N+1): for k in range(j+1): for s in range(X*N+1): dp[j][k][s] = dp[j-1][k][s] if s >= x[j-1]: dp[j][k][s] += dp[j-1][k-1][s-x[j-1]] for i in range(1,N+1): ans += dp[-1][i][i*A] if (i+1)*A > X*N: break print(ans)
Traceback (most recent call last): File "/tmp/tmp8jcqp1cc/tmpxdn12gwz.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s619645952
p04015
u285443936
1568686447
Python
PyPy3 (2.4.0)
py
Runtime Error
354
92636
437
N, A = map(int, input().split()) x= [int(i) for i in input().split()] X = max(x) dp = [[[0]*(X*N+1) for i in range(N+1)] for j in range(N+1)] dp[0][0][0] = 1 ans = 0 for j in range(1,N+1): for k in range(j+1): for s in range(X*N+1): dp[j][k][s] = dp[j-1][k][s] if s >= x[j-1]: dp[j][k][s] += dp[j-1][k-1][s-x[j-1]] for i in range(1,N+1): ans += dp[-1][i][i*A] if (i+1)*A >= X*N: break print(ans)
Traceback (most recent call last): File "/tmp/tmpu9tin0wv/tmp8dwb_m3g.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s693001426
p04015
u285443936
1568561000
Python
PyPy3 (2.4.0)
py
Runtime Error
439
92892
397
N, A = map(int, input().split()) x = [int(i) for i in input().split()] ans = 0 X = max(x) dp = [[[0]*(X*N+1) for j in range(N+1)] for k in range(N+1)] dp[0][0][0] = 1 for j in range(1,N+1): for k in range(N+1): for s in range(X*N+1): dp[j][k][s] = dp[j-1][k][s] if s>=x[j-1]: dp[j][k][s] += dp[j-1][k-1][s-x[j-1]] for k in range(1,N+1): ans += dp[N][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpyifnyjcz/tmpsdvgq3pb.py", line 1, in <module> N, A = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s336919677
p04015
u708255304
1568485371
Python
Python (3.4.3)
py
Runtime Error
2107
56052
892
N, A = map(int, input().split()) # N枚のカード, 平均をAにしたい X = list(map(int, input().split())) # カードリスト # [カードの総枚数][選んだカードの枚数][今の総和] dp = [[[0]*(max(X)*N+1) for _ in range(N+1)] for _ in range(N+1)] # 0枚の中から0枚選んで総和が0になるパターンは1つ dp[0][0][0] = 1 for i in range(len(X)): for j in range(1, N+1): for k in range(1, N+1): for s in range(1, max(X)*N+1): if s < X[i]: dp[j][k][s] = dp[j-1][k][s] if s >= X[i]: # すでにsになっているものと、今見ているカードを加えることでsになるもの dp[j][k][s] = dp[j-1][k][s] + dp[j-1][k-1][s-X[i]] ans = 0 for j in range(1, N+1): for k in range(1, N+1): ans += dp[j][k][k*A] print(ans)
Traceback (most recent call last): File "/tmp/tmpet0fphr9/tmp511i7led.py", line 1, in <module> N, A = map(int, input().split()) # N枚のカード, 平均をAにしたい ^^^^^^^ EOFError: EOF when reading a line
s236474779
p04015
u310678820
1568229301
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38256
531
import math n = int(input()) s = int(input()) def solve(n, s): if n == s: return n+1 for b in range(2, math.floor(n**0.5)+1): tmp = n res = 0 while tmp>=b: res+=tmp%b tmp //=b res += tmp if res == s: return b for p in range(int(n**0.5), 0, -1): r = s-p if r<0: continue if (n-r)%p == 0: b = (n-r)//p if r<b and b*b>n: return b return -1 print(solve(n, s))
Traceback (most recent call last): File "/tmp/tmp710mh9w8/tmpvk_gfvxo.py", line 2, in <module> n = int(input()) ^^^^^^^ EOFError: EOF when reading a line
s389238729
p04015
u077291787
1567243334
Python
Python (3.4.3)
py
Runtime Error
21
3316
392
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C) from collections import defaultdict def main(): N, A = tuple(map(int, input().split())) X = tuple(map(int, input().split())) Y = [i - A for i in X] D = defaultdict(int) D[0] = 1 for i in Y: for j, k in D.items(): D[i + j] += k print(D[0] - 1) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmp8g_fut1z/tmpiemzrocj.py", line 18, in <module> main() File "/tmp/tmp8g_fut1z/tmpiemzrocj.py", line 6, in main N, A = tuple(map(int, input().split())) ^^^^^^^ EOFError: EOF when reading a line
s128839881
p04015
u077291787
1567239340
Python
PyPy3 (2.4.0)
py
Runtime Error
260
91740
745
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C) import sys sys.setrecursionlimit(10 ** 9) def main(): N, A = tuple(map(int, input().rstrip().split())) X = tuple(map(int, input().rstrip().split())) x = max(X) # dp[i][j][k] := patterns to make k by j cards from X1, X2, ..., Xi dp = [[[0] * (N * x + 1) for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(N * x + 1): if dp[i][j][k]: dp[i + 1][j][k] += dp[i][j][k] dp[i + 1][j + 1][k + X[i]] += dp[i][j][k] ans = sum(dp[N][i][i * A] for i in range(1, N + 1)) print(ans) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmpsv0cdzuu/tmpbu5bkwsa.py", line 24, in <module> main() File "/tmp/tmpsv0cdzuu/tmpbu5bkwsa.py", line 7, in main N, A = tuple(map(int, input().rstrip().split())) ^^^^^^^ EOFError: EOF when reading a line
s944635237
p04015
u077291787
1567239305
Python
Python (3.4.3)
py
Runtime Error
784
62956
745
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C) import sys sys.setrecursionlimit(10 ** 9) def main(): N, A = tuple(map(int, input().rstrip().split())) X = tuple(map(int, input().rstrip().split())) x = max(X) # dp[i][j][k] := patterns to make k by j cards from X1, X2, ..., Xi dp = [[[0] * (N * x + 1) for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(N * x + 1): if dp[i][j][k]: dp[i + 1][j][k] += dp[i][j][k] dp[i + 1][j + 1][k + X[i]] += dp[i][j][k] ans = sum(dp[N][i][i * A] for i in range(1, N + 1)) print(ans) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmplhs7_dic/tmp2esl6moy.py", line 24, in <module> main() File "/tmp/tmplhs7_dic/tmp2esl6moy.py", line 7, in main N, A = tuple(map(int, input().rstrip().split())) ^^^^^^^ EOFError: EOF when reading a line
s514549588
p04015
u077291787
1567239252
Python
Python (3.4.3)
py
Runtime Error
785
62964
701
# ABC044C - 高橋君とカード / Tak and Cards (ARC060C) def main(): N, A = tuple(map(int, input().rstrip().split())) X = tuple(map(int, input().rstrip().split())) x = max(X) # dp[i][j][k] := patterns to make k by j cards from X1, X2, ..., Xi dp = [[[0] * (N * x + 1) for _ in range(N + 1)] for _ in range(N + 1)] dp[0][0][0] = 1 for i in range(N): for j in range(N): for k in range(N * x + 1): if dp[i][j][k]: dp[i + 1][j][k] += dp[i][j][k] dp[i + 1][j + 1][k + X[i]] += dp[i][j][k] ans = sum(dp[N][i][i * A] for i in range(1, N + 1)) print(ans) if __name__ == "__main__": main()
Traceback (most recent call last): File "/tmp/tmpqnokr_ye/tmpmbto_6s_.py", line 20, in <module> main() File "/tmp/tmpqnokr_ye/tmpmbto_6s_.py", line 3, in main N, A = tuple(map(int, input().rstrip().split())) ^^^^^^^ EOFError: EOF when reading a line
s282649498
p04015
u918935103
1567135755
Python
Python (3.4.3)
py
Runtime Error
829
19444
669
n,a = map(int,input().split()) x = list(map(int,input().split())) dp = [] for i in range(n+1): dp.append([[] for j in range(i+1)]) for k in range(i+1): dp[i][k] = [0 for y in range(50*k)] for i in range(n+1): dp[i][0].append(0) for i in range(1,n+1): for j in range(1,i+1): if j == 1: dp[i][j][x[i-1]-1] += 1 for k in range(len(dp[i-1][j-1])): dp[i][j][k+x[i-1]] += dp[i-1][j-1][k] dp[i][j-1][k] += dp[i-1][j-1][k] count = 0 for j in range(1,i+1): for k in range(len(dp[i][j])): if k + 1 == j*a: count += dp[n][j][k] print(count)
Traceback (most recent call last): File "/tmp/tmpmo2abvgs/tmpb33ncibp.py", line 1, in <module> n,a = map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line
s090175033
p04015
u484229314
1566001215
Python
Python (3.4.3)
py
Runtime Error
2109
21256
682
import numpy as np N, A = [int(v) for v in input().split()] X = [0, ] + [int(v) for v in input().split()] mx = sum(X) dp = np.zeros((N + 1, N + 1, mx + 1)) dp[0][0][0] = 1 for j in range(1, N + 1): for k in range(N + 1): for s in range(mx + 1): if s - X[j] < 0: dp[j][k][s] += dp[j - 1][k][s] elif k > 0: dp[j][k][s] += dp[j - 1][k - 1][s - X[j]] + dp[j - 1][k][s] # print('err') # for debug else: dp[j][k][s] = 0 ans = 0 # print(dp) i = 1 while i * A <= sum(X): # print(i * A, dp[N, i, i * A].sum()) ans += dp[N, i, i * A].sum() i += 1 print(int(ans))
Traceback (most recent call last): File "/tmp/tmpeb9ocij5/tmp_d_u8ah1.py", line 3, in <module> N, A = [int(v) for v in input().split()] ^^^^^^^ EOFError: EOF when reading a line
s630438952
p04015
u399721252
1565369684
Python
PyPy3 (2.4.0)
py
Runtime Error
279
42860
437
n, a = [ int(v) for v in input().split() ] num_list = [ int(v) for v in input().split() ] max_num = max(num_list) field = [ [ 0 for i in range(max_num*n+1) ] for i in range(n+1) ] field[0][0] = 1 b = num_list[0] for i in num_list: for j in range(n,0,-1): for k in range(max_num*n+1): if k >= i: field[j][k] += field[j-1][k-i] ans = 0 for i in range(1,n+1): ans += field[i][a*i] print(ans)
Traceback (most recent call last): File "/tmp/tmpd1qbzj97/tmpss56g42g.py", line 1, in <module> n, a = [ int(v) for v in input().split() ] ^^^^^^^ EOFError: EOF when reading a line
s030176349
p04015
u091051505
1564702944
Python
Python (3.4.3)
py
Runtime Error
329
56436
396
n, a = map(int, input().split()) x = [int(i) for i in input().split()] dp = [[[0 for _ in range(((n * a) + 1))] for _ in range(n + 1)] for _ in range(n + 1)] dp[0][0][0] = 1 for j in range(1, n + 1): for k in range(n + 1): for s in range((n * a) + 1): dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k][s - X[j - 1]] ans = sum([dp[n][i+1][(i+1)*a] for i in range(n)]) print(ans)
Traceback (most recent call last): File "/tmp/tmpi06xwxax/tmpzepf3y7m.py", line 1, in <module> n, a = map(int, input().split()) ^^^^^^^ EOFError: EOF when reading a line
s558740126
p04015
u977193988
1562506977
Python
Python (3.4.3)
py
Runtime Error
1764
134260
199
n,a=map(int,input().split()) X=[int(i)-a for i in input().split()] memo={0:1} for x in X: for k,v in list(memo.items()): memo[x+k]=memo.get(x+k,0)+v print(memo) print(memo[0]-1)
Traceback (most recent call last): File "/tmp/tmpg98i0ahj/tmpkyoleih6.py", line 1, in <module> n,a=map(int,input().split()) ^^^^^^^ EOFError: EOF when reading a line