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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
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... |
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 ... |
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_e... |
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 isi... |
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... |
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... |
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:
... |
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 ... |
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
... |
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
... |
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
... |
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
... |
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())... |
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:
... |
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:
... |
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)
... |
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):
... |
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... |
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.set... |
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:
... |
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:
... |
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:
... |
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)
brea... |
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)//... |
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_r... |
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):... |
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):
... |
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)
... |
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)
... |
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)... |
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
... |
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... |
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):
... |
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
whil... |
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... |
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 |
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(... |
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):
... |
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 -... |
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:
... |
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
... |
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 -... |
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 -... |
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 = ... |
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
... |
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... |
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:
pri... |
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
... |
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)... |
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)... |
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) |
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) |
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) |
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 se... |
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... |
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):
... |
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) |
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]
... |
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]) |
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+... |
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]
prin... |
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] =... |
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:
... |
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 ... |
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... |
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
... |
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.factoria... |
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.factoria... |
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 ... |
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):
fo... |
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):
fo... |
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]
... |
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]
... |
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]
... |
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]
... |
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]... |
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... |
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
... |
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:
... |
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)) |
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... |
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 ran... |
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]: #... |
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):
... |
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):
... |
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) |
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] += d... |
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] += d... |
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... |
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, ... |
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(... |
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
... |
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)... |
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)... |
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... |
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:... |
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] += ... |
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:
... |
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]... |
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)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.