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
s553250128
p03999
u038815010
1590328709
Python
Python (3.4.3)
py
Runtime Error
22
2940
193
s=input() d=[] n=len(s) ans=0 for i in range(1<<n): tmp=0 for j in range(n): if (i>>j)&1: ans+=int(s[tmp:j+1]) tmp=j+1 ans+=int(s[tmp:]) print(ans)
s430793400
p03999
u106778233
1589987160
Python
Python (3.4.3)
py
Runtime Error
18
3060
215
S=str(input()) n=len(S) cnt=0 for i in range(2**(n-1)): s=S for j in range(n-1): if i>>j&1: cnt+=int(s[:j+1]) s=s[j+1:] pass cnt+=int(s) print(cnt)
s634501245
p03999
u503227287
1589754028
Python
PyPy3 (2.4.0)
py
Runtime Error
182
41196
632
from sys import stdin if __name__ == "__main__": _in = [_.rstrip() for _ in stdin.readlines()] S_arr = _in[0] # type:list(int) # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv N = len(S_arr)-1 cnt = 0 for bit in range(1<<N): # bit = 0: '', 1: '+' tmp = [] pointa = 0 for i in range(N): if bit&(1<<i): tmp.append(int(S_arr[pointa:i+1])) pointa = i+1 else: i+=1 tmp.append(int(S_arr[pointa:i+1])) cnt += sum(tmp) # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ print(cnt)
s403443460
p03999
u127499732
1589492640
Python
PyPy2 (5.6.0)
py
Runtime Error
36
28396
306
def main(): s = input() n = len(s) ans = 0 for i in range(n + 1): for j in range(i + 1, n + 1): x = int(s[i:j]) p = 2 ** max(0, i - 1) q = 2 ** max(0, n - j - 1) ans += x * p * q print(ans) if __name__ == '__main__': main()
s947982948
p03999
u127499732
1589492399
Python
Python (2.7.6)
py
Runtime Error
10
2568
306
def main(): s = input() n = len(s) ans = 0 for i in range(n + 1): for j in range(i + 1, n + 1): x = int(s[i:j]) p = 2 ** max(0, i - 1) q = 2 ** max(0, n - j - 1) ans += x * p * q print(ans) if __name__ == '__main__': main()
s056815605
p03999
u588785393
1589423837
Python
Python (3.8.2)
py
Runtime Error
26
9216
563
def calc(n): if n <= 1: return 1 else: return 2 ** (n - 1) def normailze(s, n): return (n - len(s)) * '0' + s def solve(s): a = calc(len(s)) cnt = 0 n = len(s) for i in range(a): binary = normailze(bin(i)[2:], n - 1) b = s[0] f = 1 for j in binary: if int(j) == 1: cnt += int(b) b = s[f] f += 1 else: b += s[f] f += 1 cnt += int(b) return cnt print(solve(input()))
s238752039
p03999
u623687794
1589411857
Python
Python (3.4.3)
py
Runtime Error
17
3060
210
import itertools s=input() ans=0 L=len(s) for sta in itertools.product(range(2),L): cut=[-1]+[i for i in range(L) if sta[i]]+[L-1] for i in range(len(cut)-1): ans+=int(s[cut[i]+1:cut[i+1]+1]) print(ans)
s449688687
p03999
u691018832
1589233629
Python
Python (3.4.3)
py
Runtime Error
20
3064
507
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from itertools import product s = read().rstrip().decode() ans = 0 for bit in product(['', '+'], repeat=len(s) - 1): memo = 0 for i, (bf, af) in enumerate(zip(s, s[1:])): memo += int(bf) if bit[i] == '+': ans += memo memo = 0 else: memo *= 10 memo += int(af) ans += memo print(ans)
s986934052
p03999
u094191970
1589085691
Python
Python (3.4.3)
py
Runtime Error
21
3316
461
from collections import deque n,m=map(int,input().split()) tree=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 tree[a].append(b) tree[b].append(a) dist=[-1 for i in range(n)] dist[0]=0 dq=deque() dq.append(0) while dq: x=dq.popleft() if x==n-1: if dist[x]==2: print('POSSIBLE') else: print('IMPOSSIBLE') for i in tree[x]: if dist[i]==-1: dist[i]=dist[x]+1 dq.append(i)
s986088913
p03999
u547608423
1589076942
Python
Python (3.4.3)
py
Runtime Error
20
3064
443
S=input() s=list(S) ans=0 for i in range(2**(len(s)-1)): judge=str(bin(i))[2:].rjust(len(s)-1,"0") sum=0 plus=s[0] #print(judge) for j,jud in enumerate(judge): if jud=="0": plus+=s[j+1] #print(plus) else: sum+=int(plus) plus="" plus+=s[j+1] if len(plus)!=0: sum+=int(plus) #print(plus) #print(sum) ans+=sum print(ans)
s843794955
p03999
u919025034
1588964381
Python
PyPy3 (2.4.0)
py
Runtime Error
182
39920
303
S=list(input()) ans=0 for i in range(2**(len(S)-1)): bin_i= format(i, 'b') bin_i=str(bin_i.zfill(len(S)-1)) s=0 l=int(S[0]) for j,k in enumerate(bin_i): if k=="0": l=l*10+int(S[j+1]) else: s+=l l=int(S[j+1]) if j==len(S)-2: s+=l ans+=s print(ans)
s387884087
p03999
u366541443
1588495431
Python
PyPy3 (2.4.0)
py
Runtime Error
177
38384
413
ss = input() n = len(ss) s=[] for i in range(n): s.append(int(ss[i])) ans = 0 for i in range(2**(n-1)): d=[[]] bit = ValueToBits(i,n-1) for j in range(n-1): d[-1].append(s[j]) if(bit[j]==1): d.append([]) d[-1].append(s[n-1]) #print(d) for j in d: for k in range(len(j)): ans += 10**(len(j)-1-k) * j[k] print(ans)
s577199984
p03999
u375616706
1588364339
Python
Python (3.4.3)
py
Runtime Error
18
3060
214
S = int(input()) N = len(S) ans=0 for bit in range(1<<(N-1)): f = S[0] for i in range(N-1): if bit & (1<<i): f +="+" f+=S[i+1] ans += sum(map(int,f.split("+"))) print(ans)
s336566228
p03999
u578323547
1588292033
Python
Python (3.4.3)
py
Runtime Error
17
3064
410
patterns = [] for i in range(2**(l-1)): pattern = [''] * (l-1) for j in range(l-1): if (i >> j & 1): pattern[j] = '+' patterns.append(pattern) ans = 0 for pattern in patterns: a = s[0] for i in range(l-1): if (pattern[i] == ''): a += s[i+1] else: ans += int(a) a = s[i+1] else: ans += int(a) print(ans)
s533896688
p03999
u028014940
1587235333
Python
Python (3.4.3)
py
Runtime Error
18
3064
199
s = input() n = len(s) def dfs(i, f): if i == n - 1: return sum(list(map(int, f.split("+")))) return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1]) print(dfs(0, s[0]))
s594891437
p03999
u028014940
1587235188
Python
PyPy3 (2.4.0)
py
Runtime Error
179
38640
222
s = input() n = len(s) start = time.time() def dfs(i, f): if i == n - 1: return sum(list(map(int, f.split("+")))) return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1]) print(dfs(0, s[0]))
s837516852
p03999
u672542358
1586751298
Python
Python (3.4.3)
py
Runtime Error
18
3064
162
s=input() n=len(s) def dfs(i,k): if i<n-1: return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1]) return sum(list(map(int,input().split("+")))) print(dfs(0,s[0]))
s390828553
p03999
u672542358
1586751264
Python
Python (3.4.3)
py
Runtime Error
17
2940
161
s=input() n=len(s) def dfs(i,k): if i<n-1: return dfs(i+1,k+s[i+1])+dfs(i+1,k+"+"+s[i+1]) return sum(list(map(int,input().split("+")))) print(dfs(0,s[0])
s472357452
p03999
u708019102
1585952077
Python
Python (3.4.3)
py
Runtime Error
40
3956
428
import copy a = list(input()) n = len(a)-1 ans = 0 for i in range(2 ** n): l=[] l = copy.copy(a) dokoka = [0]*(n) for j in range(n): if ((i >> j)&1): dokoka[j] = 1 x = l.pop(0) while True: d = dokoka.pop(0) if d == 0: x += l.pop(0) else: ans += int(x) x = l.pop(0) if not dokoka: ans += int(x) break print(ans)
s326661314
p03999
u452269253
1585767158
Python
Python (3.4.3)
py
Runtime Error
27
3060
245
S = list(input()) t = 0 for n in range(2**(len(S) - 1)): f = S[0] b = bin(n)[2:] b = "0"*(len(S) - len(b) - 1) + b for a in range(len(b)): if b[a] == "1": f += "+" f += S[a+1] t += eval(f) print(t)
s683515114
p03999
u923270446
1584563844
Python
Python (3.4.3)
py
Runtime Error
18
2940
197
def dfs(i, f): if i == len(s) - 1: return sum(list(map(int, f.split("+")))) return dfs(i + 1, f + s[i + 1]) + \ dfs(i + 1, f + "+" + s[i + 1]) s = input() print(dfs(0, s[0]))
s982335177
p03999
u923270446
1584563631
Python
Python (3.4.3)
py
Runtime Error
17
2940
192
def dfs(i, f): if i == len(s) - 1: return sum(list(map(int, f.split("+")))) return dfs(i + 1, f + s[i + 1]) + \ dfs(i + 1, f + "+" + s[i + 1]) s = input() print(dfs(0, s[0]))
s111668091
p03999
u934868410
1584064087
Python
Python (3.4.3)
py
Runtime Error
17
2940
220
s = input() n = len(s) ans = 0 for i in range(2**(n-1)): plus = [0] for j in range(n-1): if (i >> j) & 1 = 1: plus += [j+1] for j in range(len(plus)-1): ans += int(s[plus[j]:plus[j+1]]) print(ans)
s519222453
p03999
u990300472
1583888994
Python
Python (3.4.3)
py
Runtime Error
17
3064
380
S = [int(i) for i in input()] N = len(S) tens = [10**i for i in range(N)] tens.reverse() twos = [1] twos.extend(2**i for i in range(N-1)) sums = 0 all_comb = sum(twos) for i in range(N): tmp = [x*y for x, y in zip(tens[i:], twos)] exp = S[i] * sum(tmp) / sum(twos) print(exp) sums = sums + exp del twos[-1] print(sums * all_comb) sum(map(mul, tens,twos))
s802364105
p03999
u686036872
1583628527
Python
PyPy3 (2.4.0)
py
Runtime Error
170
38512
186
S=input() ans=0 for i in range(2**(len(S)-1)): tmp=S[0] for j in range(len(S)-1): if ((i >> j) & 1) == 1: x+="+" x+=S[j+1] ans+=eval(x) print(ans)
s416269007
p03999
u375695365
1582699421
Python
Python (3.4.3)
py
Runtime Error
19
3064
596
s=str(input()) n=len(s)-1 #print(s,n) #print(xy) bit=[]#1が正直0が嘘 ans=0 def bit_search(bit): global ans count=[] c=0 if len(bit)==n:#2**n文の組み合わせを調べる加圧10を交互に入れるためのif for i in range(n): if bit[i]==1: count.append(int(s[c:i])) c=i count.append(int(s[c:n])) ans+=sum(count) else: #再起化することによって最初にbitの配列を作る必要性をなくした bit_search(bit+[0]) bit_search(bit+[1]) bit_search(bit) print(ans)
s551019233
p03999
u736729525
1581830681
Python
PyPy3 (2.4.0)
py
Runtime Error
180
38256
444
N = int(input()) TA = [] for i in range(N): T, A = map(int, input().split()) TA.append((T, A)) T, A = TA[0] answer = T+A p = 1 prev = p pT, pA = T, A for i in range(1,N): # (T+A) * p >= prev # p >= prev/(T+A) T, A = TA[i] s = T+A p = (answer+s-1)//s p1 = (pT+T-1)//T p2 = (pA+A-1)//A p = max([p,p1,p2]) pT, pA = p*T, p*A answer = pT+pA #print(T, A, p, answer, sep="\t") print(answer)
s023270911
p03999
u987164499
1581486624
Python
Python (3.4.3)
py
Runtime Error
2111
73460
827
from sys import stdin n = int(stdin.readline().rstrip()) li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(n)] point = 0 for i in range(101): for j in range(101): flag = True kizyun = False count = 0 for a,b,c in li: if c != 0: count += 1 if kizyun == False: h = c+abs(a-i)+abs(b-j) if h-abs(a-i)-abs(b-j) != c: flag = False kizyun = True else: k = c+abs(a-i)+abs(b-j) if h != k and kizyun == True: flag = False if count == 1: print(a,b,c) exit() if flag == True: point += 1 print(i,j,h)
s684640252
p03999
u506287026
1580455297
Python
Python (3.4.3)
py
Runtime Error
26
3060
270
s = input() n = len(s) - 1 ans = 0 for i in range(2 ** n): tmp = '' for j in range(n): tmp += s[j] if i & 1 << j: tmp += '+' tmp += s[j+1] if '+' in tmp: ans += eval(tmp) else: ans += int(tmp) print(ans)
s723604931
p03999
u193019328
1579651445
Python
Python (3.4.3)
py
Runtime Error
17
2940
117
a = input() sum = int(a) for i in range(len(a)): if i==0: continue sum += int(a[:i])+int(a[i+1:]) print(sum)
s891559204
p03999
u314089899
1579310327
Python
Python (3.4.3)
py
Runtime Error
20
3064
487
#045c S = list(input()) #allは2**9=512なので全探索でOK ans = 0 for i in range(0,2**(len(S)-1)): bit = str(bin(i))[2:].zfill(len(S)-1) #print(bit,":",end="") number = int(S[0]) for j in range(len(bit)): if bit[j] == "0": number = number*10 + int(S[j+1]) else: #print("+",number,end="") ans += number number = int(S[j+1]) #print("+",number) ans += number print(ans)
s882139291
p03999
u947327691
1579118359
Python
Python (3.4.3)
py
Runtime Error
17
2940
2
ss
s801149704
p03999
u152638361
1578549438
Python
Python (3.4.3)
py
Runtime Error
28
3060
346
S = list(input()) form = "0"+str(len(S)-1)+"b" ans = 0 for i in range(2**(len(S)-1)): b = format(i, form) eq = [S[0]] for j in range(len(b)): if b[j] == "1": sign = "+" else: sign = "" eq.append(sign) eq.append(S[j+1]) eqstr = str("".join(eq)) ans += eval(eqstr) print(ans)
s737831494
p03999
u489124637
1577816499
Python
PyPy3 (2.4.0)
py
Runtime Error
161
38384
354
S = input() Ans = 0 box = [] for i in range(2 ** (len(S)-1)): # 文字の間に挿入するので、len(S)-1 for j in range((len(S)-1)): box.append(S[j]) if (i >> j) & 1: Ans += int("".join(box)) box.clear() box.append(S[-1]) Ans += int("".join(box)) box.clear() print(Ans)
s478825887
p03999
u768896740
1577415087
Python
Python (3.4.3)
py
Runtime Error
21
3064
322
a = input() ans = 0 for i in range(2**(len(a)-1)): b = format(i, 'b').zfill((len(a)-1)) li = [] num = [a[0]] for i in range(len(b)): if b[i] == '1': ans += int(''.join(num)) num = [a[i+1]] else: num.append(a[i+1]) ans += int(''.join(num)) print(ans)
s289206271
p03999
u492447501
1577259111
Python
Python (3.4.3)
py
Runtime Error
22
3444
319
import sys import copy S = input() op_list = ["+"]*(len(S)-1) sum = 0 for i in range(2**len(op_list)): for j in range(len(op_list)): if (i >> j) & 1: op_list[j] = "" s = "" for k in range(len(op_list)): s = s + S[k] + op_list[k] sum = sum + eval(s) print(sum)
s858047480
p03999
u002459665
1576729854
Python
Python (3.4.3)
py
Runtime Error
27
3064
369
def main(): S = input() lens = len(S) patterns = [] ans = 0 for i in range(2 ** (lens-1)): x = format(i, 'b').zfill(lens-1) stmt = S[0] for i, xi in enumerate(x): if xi == '1': stmt += '+' stmt += S[i+1] ans += eval(stmt) print(ans) if __name__ == "__main__": main()
s117374039
p03999
u002459665
1576729625
Python
Python (3.4.3)
py
Runtime Error
27
3064
407
from itertools import combinations def main(): S = input() lens = len(S) patterns = [] ans = 0 for i in range(2 ** (lens-1)): x = format(i, 'b').zfill(lens-1) stmt = S[0] for i, xi in enumerate(x): if xi == '1': stmt += '+' stmt += S[i+1] ans += eval(stmt) print(ans) if __name__ == "__main__": main()
s096981018
p03999
u311379832
1575270942
Python
Python (3.4.3)
py
Runtime Error
26
3064
515
S = input() p = [1] * (len(S) - 1) sumlst = [0] * len(S) ans = 0 def dfs(i): global ans if i == (len(S) - 1): tmp = '' if p[0] == 1: tmp += S[0] + '+' + S[1] else: tmp += S[0] + S[1] for i in range(1, len(p)): if p[i] == 1: tmp += '+' + S[i + 1] else: tmp += S[i + 1] ans += eval(tmp) return p[i] = 1 dfs(i + 1) p[i] = 0 dfs(i + 1) return dfs(0) print(ans)
s576365101
p03999
u457554982
1574873156
Python
Python (3.4.3)
py
Runtime Error
17
3060
238
s=list(input()) n=len(s) for i in range(2**(n-1)): ni=list(map(int,list(str(format(i,"b"))))) while len(ni)<n-1: ni.insert(0,0) siki=s[0] for j in range(n-1): if ni[j]==1: siki+="+" siki+=s[j+1] ans+=eval(siki) print(ans)
s122875788
p03999
u256031597
1571365769
Python
Python (3.4.3)
py
Runtime Error
18
3064
292
Sl = list(input()) def func(n, s): n += 1 if n==len(Sl)-1: a = sum([int(i) for i in (s+Sl[n]).split("+")]) b = sum([int(i) for i in (s+"+"+Sl[n]).split("+")]) return a + b else: return func(n, s+Sl[n]) + func(n, s+"+"+Sl[n]) print(func(0, Sl[0]))
s467220567
p03999
u100800700
1570804819
Python
Python (3.4.3)
py
Runtime Error
17
3060
160
s=input() n=len(s) def dfs(i,x): if i==n-1: return sum(list(int,x.split('+'))) return dfs(i+1,x+s[i+1])+dfs(i+1,x+'+'+s[i+1]) print(dfs(0,s[0]))
s208562937
p03999
u100800700
1570804773
Python
Python (3.4.3)
py
Runtime Error
17
2940
18
print(dfs(0,s[0]))
s887403641
p03999
u829008868
1570686879
Python
Python (3.4.3)
py
Runtime Error
16
2940
180
S = input() n = lens(S) def dfs(i,k): if i == n-1: return(sum(list(map(int,f.split("+"))) return dfs(i+1,K+S[i+1])+dfs(i+1,K+"+"+S[i+1]) print(dfs(0,S[0])
s607994762
p03999
u009348313
1570674246
Python
PyPy3 (2.4.0)
py
Runtime Error
215
41712
305
S = input() if len(S) == 1: print(int(S)) else: ans = 0 for i in range(1<<(len(S)-1)): SP = [] for j in range(len(S)-1): if (i>>j)&1 == 1: SP.append(j) SP += [len(S)-1] #print(SP) idx = 0 for sp in SP: ans += int(S[idx:sp+1]) idx = sp+1 print(ans)
s939329041
p03999
u100800700
1570574422
Python
Python (3.4.3)
py
Runtime Error
17
3060
169
s=input() n=len(s) def f(i,t): if i == n-1: return sum(list(map(int, t.split('+')))) return f(i+1,f+s[i+1]) + f(i+1,f+'+'+s[i+1]) print(f(0,s[0]))
s843523799
p03999
u422029490
1570222565
Python
Python (3.4.3)
py
Runtime Error
17
3060
265
s = input() sum = 0 for bit in range(1 << (len(s) - 1)): expr = s ins = 0 for i in range(len(s) - 1): ins += i if bit & 1 << i: expr = expr[:ins+1] + '+' + expr[ins+1:] ins += 1 sum += eval(expr) print(sum)
s418258270
p03999
u891635666
1570096855
Python
Python (3.4.3)
py
Runtime Error
27
3060
246
s = input().rstrip() n = len(s) res = 0 for i in range(2**(n - 1)): bs = bin(i)[2:].rjust(n - 1, '0') ss = s[0] for j, b in enumerate(bs, 1): if b == '1': ss += '+' ss += s[j] res += eval(ss) print(res)
s090451741
p03999
u120386623
1569382554
Python
Python (3.4.3)
py
Runtime Error
46
5100
824
import math import sys import itertools import queue from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) mod = 1000000007 if __name__ == "__main__": s = sys.stdin.readline() ans = 0 n = len(s) for i in range(2**(n-1)):#数字文字列の間に「+」を入れる/入れないの全パターン tmp=s[0]#左端の値をとってくる for j in range(n-1):#2進数のフラグチェック if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。 tmp+="+"#入れる tmp+=s[j+1]#後半をつなぐ # print("tmp:",tmp) ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる print(ans)
s392488743
p03999
u120386623
1569382503
Python
Python (3.4.3)
py
Runtime Error
18
2940
605
s = sys.stdin.readline() ans = 0 n = len(s) for i in range(2**(n-1)):#数字文字列の間に「+」を入れる/入れないの全パターン tmp=s[0]#左端の値をとってくる for j in range(n-1):#2進数のフラグチェック if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。 tmp+="+"#入れる tmp+=s[j+1]#後半をつなぐ # print("tmp:",tmp) ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる print(ans)
s726413549
p03999
u120386623
1569382377
Python
Python (3.4.3)
py
Runtime Error
63
5608
1428
""" # 標準入力取得 ## 文字列 = sys.stdin.readline().rstrip() = list(sys.stdin.readline().rstrip()) ## 数値 = int(sys.stdin.readline()) = map(int, sys.stdin.readline().split()) = list(map(int, sys.stdin.readline().split())) = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # 0埋め, 小数点出力桁指定時のときの出力 a = 100 b = 0.987654321 print("{0:06d}-{1:6f}".format(a,b)) 000100-0.987654 # 文字列をリストに格納 char_list = list("abcd") # ["a","b","c","d"] """ import math import sys import itertools import queue from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) mod = 1000000007 if __name__ == "__main__": s = sys.stdin.readline() ans = 0 n = len(s) for i in range(2**(n-1)):#数字文字列の間に「+」を入れる/入れないの全パターン tmp=s[0]#左端の値をとってくる for j in range(n-1):#2進数のフラグチェック if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。 tmp+="+"#入れる tmp+=s[j+1]#後半をつなぐ # print("tmp:",tmp) ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる print(ans)
s435823588
p03999
u120386623
1569382317
Python
Python (3.4.3)
py
Runtime Error
47
5096
1428
""" # 標準入力取得 ## 文字列 = sys.stdin.readline().rstrip() = list(sys.stdin.readline().rstrip()) ## 数値 = int(sys.stdin.readline()) = map(int, sys.stdin.readline().split()) = list(map(int, sys.stdin.readline().split())) = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)] # 二次元配列入力 二次元マップみたいな入力のとき # 0埋め, 小数点出力桁指定時のときの出力 a = 100 b = 0.987654321 print("{0:06d}-{1:6f}".format(a,b)) 000100-0.987654 # 文字列をリストに格納 char_list = list("abcd") # ["a","b","c","d"] """ import math import sys import itertools import queue from fractions import gcd def lcm(a, b): return a * b // gcd(a, b) mod = 1000000007 if __name__ == "__main__": s = sys.stdin.readline() ans = 0 n = len(s) for i in range(2**(n-1)):#数字文字列の間に「+」を入れる/入れないの全パターン tmp=s[0]#左端の値をとってくる for j in range(n-1):#2進数のフラグチェック if i&(1<<j):#&は論理積。jを左に一回シフトして最下位の値がiかどうかチェック。 tmp+="+"#入れる tmp+=s[j+1]#後半をつなぐ # print("tmp:",tmp) ans += eval(tmp) #eval()の引数に実行したい「式」を文字列として渡すと、その実行結果が帰ってくる print(ans)
s865708609
p03999
u433532588
1569271889
Python
Python (3.4.3)
py
Runtime Error
28
3064
615
import sys input = sys.stdin.readline sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 # A = [ int(input()) for _ in range(N) ] ############################## S = input().rstrip() l = list(S) N = len(l) def getbit(i, length): return format(i, '0' + str(length) + 'b') bits = [] for i in range(2**(N-1)): bits.append(getbit(i, N-1)) ans = 0 for i in range(len(bits)): s = str(l[0]) bitlist = list(bits[i]) for j in range(len(bitlist)): if bitlist[j] == '0': pass else: s += '+' s += str(l[j+1]) ans += eval(s) print(ans)
s188451520
p03999
u360094607
1568747550
Python
Python (3.4.3)
py
Runtime Error
18
3060
375
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=sys.stdin.readline def resolve(): s=input() n=len(s) ans=0 from itertools import product for A in product(range(2),repeat=n-1): k=s[0] for i in range(n-1): k+='+' if A[i] else '' k+=s[i+1] ans+=eval(k) print(ans) resolve()
s048564148
p03999
u440566786
1568744905
Python
PyPy3 (2.4.0)
py
Runtime Error
165
38256
374
import sys sys.setrecursionlimit(2147483647) INF=float("inf") MOD=10**9+7 input=sys.stdin.readline def resolve(): s=input() n=len(s) ans=0 from itertools import product for A in product(range(2),repeat=n-1): k=s[0] for i in range(n-1): k+='+' if A[i] else '' k+=s[i+1] ans+=eval(k) print(ans) resolve()
s898794946
p03999
u666198201
1568467576
Python
Python (3.4.3)
py
Runtime Error
21
3060
273
S=input() total=0 for i in range(2**(len(S)-1)): a = int(S[0]) t=format(i,'b').zfill(len(S)-1) for j in range(len(t)): if t[j]=='0': a=a*10+int(S[j+1]) else: total+=a a=int(S[j+1]) total+=a print(total)
s552016769
p03999
u097317219
1568357064
Python
Python (3.4.3)
py
Runtime Error
17
3060
189
s = input() n = len(s) def dfs(i,f): if i == n: return sum(list(map(int,f.split("+")))) return dfs(i + 1, f + s[i + 1]) + \ dfs(i + 1, f + "+" + s[i + 1]) print(dfs(0,0))
s232733382
p03999
u231122239
1566319082
Python
Python (3.4.3)
py
Runtime Error
28
3188
224
S = input() ans = 0 for i in range(2**(len(S)-1)): tmp = S[0] for j, b in enumerate(format(i, 'b').zfill(len(S)-1)): if b == '1': tmp += '+' tmp += S[j+1] ans += eval(tmp) print(ans)
s808936163
p03999
u219086885
1566188075
Python
Python (3.4.3)
py
Runtime Error
21
3060
282
s = input() answer = 0 if len(s) == 1: print(s) for i in range(2**(len(s)-1)): f = s[0] for j,b in enumerate(str(format(i,'b').zfill(len(s)-1))): if b == '1': f += ',' f += s[j+1] answer += sum(int(i) for i in f.split(',')) print(answer)
s185867695
p03999
u219086885
1566187841
Python
Python (3.4.3)
py
Runtime Error
21
3060
252
s = input() answer = 0 for i in range(2**(len(s)-1)): f = s[0] for j,b in enumerate(str(format(i,'b').zfill(len(s)-1))): if b == '1': f += ',' f += s[j+1] answer += sum(int(i) for i in f.split(',')) print(answer)
s325466606
p03999
u626337957
1565299208
Python
Python (3.4.3)
py
Runtime Error
18
3060
418
S = input() stack = [S] ans = int(S) checked = [] while True: str_num = stack.pop() if len(str_num) <= 1: continue for i in range(len(str_num)): str1 = str_num[:i] str2 = str_num[i:] if not str1 in checked: checked.append(str1) ans += int(str1) stack.append(str1) if not str2 in checked: checked.append(str2) ans += int(str2) stack.append(str2) print(ans)
s741844693
p03999
u676059589
1564116886
Python
PyPy3 (2.4.0)
py
Runtime Error
304
66284
2158
from copy import * from sys import * import math import queue from collections import defaultdict,Counter,deque from fractions import Fraction as frac setrecursionlimit(1000000) #dp[i][j]: iまでからj枚えらんで和がkになるのは何通り def main(): s = input() ans = 0 for i in range(0,2**(len(s)-1)): temp = [] ix2 = base_10_to_n(i,2) for i in range(len(s)-len(ix2)-1): ix2 = '0' + ix2 tmp = s[0] for j in range(len(ix2)): if(ix2[j]=='1'): temp.append(tmp) tmp = s[j+1] else: tmp = tmp + s[j+1] temp.append(tmp) for i in temp: ans+=int(i) print(ans) def zip(a): mae = a[0] ziparray = [mae] for i in range(1,len(a)): if(mae != a[i]): ziparray.append(a[i]) mae = a[i] return ziparray def is_prime(n): if n < 2: return False for k in range(2, int(math.sqrt(n)) + 1): if n % k == 0: return False return True def list_replace(n,f,t): return [t if i==f else i for i in n] def base_10_to_n(X, n): X_dumy = X out = '' while X_dumy>0: out = str(X_dumy%n)+out X_dumy = int(X_dumy/n) if(out == ''): return '0' return out def gcd(m,n): x = max(m,n) y = min(m,n) while(x%y!=0): z = x%y x = y y = z return y class queue(): def __init__(self): self.q = deque([]) def push(self,i): self.q.append(i) def pop(self): return self.q.popleft() def size(self): return len(self.q) def debug(self): return self.q class stack(): def __init__(self): self.q = [] def push(self,i): self.q.append(i) def pop(self): return self.q.pop() def size(self): return len(self.q) def debug(self): return self.q class graph(): def __init__(self): self.graph = defaultdict(list) def addnode(self,l): f,t = l[0],l[1] self.graph[f].append(t) self.graph[t].append(f) def rmnode(self,l): f,t = l[0],l[1] self.graph[f].remove(t) self.graph[t].remove(f) def linked(self,f): return self.graph[f] class dgraph(): def __init__(self): self.graph = defaultdict(set) def addnode(self,l): f,t = l[0],l[1] self.graph[f].append(t) def rmnode(self,l): f,t = l[0],l[1] self.graph[f].remove(t) def linked(self,f): return self.graph[f] main()
s019995912
p03999
u927534107
1561757532
Python
Python (3.4.3)
py
Runtime Error
18
3064
214
n = str(input()) a = ["","+"] l = list(itertools.product(a,repeat=len(n)-1)) l_n = list(n) ans=0 for i in l: l_a = [None]*(len(n)*2-1) l_a[::2] = l_n l_a[1::2] = i ans+=eval("".join(l_a)) print(ans)
s986819726
p03999
u374531474
1559410843
Python
Python (3.4.3)
py
Runtime Error
28
3060
276
S = input() N = len(S) ans = 0 for i in range(2 ** (N - 1)): bit = ('{:0' + str(N - 1) + 'b}').format(i) formula = S[0] for j in range(len(bit)): if bit[j] == '1': formula += '+' formula += S[j + 1] ans += eval(formula) print(ans)
s612556483
p03999
u037430802
1557194048
Python
Python (3.4.3)
py
Runtime Error
25
3064
342
S = input() ans = 0 def dfs(num_string, p): global ans if p > len(S) - 1: #終わり ans += eval(num_string) return #先頭の数字だけ扱いが微妙 if p == 0: num_string = "" + S[0] p = 1 tmp = 0 dfs(num_string + "+" + S[p], p+1) dfs(num_string + S[p], p+1) return dfs(0,0) print(ans)
s802602502
p03999
u655834330
1556545628
Python
PyPy3 (2.4.0)
py
Runtime Error
174
38256
541
from itertools import combinations def read_input(): s = input().strip() return s def split_and_sum(s, indice): indice_e = [0, *indice, 10] result = [] for start,end in zip(indice_e, indice_e[1:]): result.append(int(s[start:end])) return sum(result) def submit(): s = read_input() max_index = len(s) acc = 0 for i in range(max_index): for c in combinations(range(1, max_index), i): acc += split_and_sum(s, c) print(acc) if __name__ == '__main__': submit()
s206754248
p03999
u859897687
1556194170
Python
Python (3.4.3)
py
Runtime Error
17
3064
221
n=input() m=[[]for _ in range(n)] m[0]+=[[0,int(n[0])]] for i in range(1,len(n)): a=int(n[i]) for m0,m1 in m[i-1]: m[i]+=[[m0+m1,a]] m[i]+=[[m0,m1*10+a]] ans=0 for m0,m1 in m[len(n)-1]: ans+=m0+m1 print(ans)
s840348633
p03999
u013408661
1554472627
Python
Python (3.4.3)
py
Runtime Error
18
3060
275
n=input() ans=0 def dfs(i,flag): global ans if i!=len(n)-1: dfs(i+1,flag) dfs(i+1,flag|2**i) else: num=[] start=0 for i in range(len(n)): if flag&2**i>0: num.append(n[start:i+1]) start=i+1 ans+=sum(num) dfs(0,0) print(ans)
s737585590
p03999
u013408661
1554472615
Python
Python (3.4.3)
py
Runtime Error
19
3064
262
n=input() ans=0 def dfs(i,flag): if i!=len(n)-1: dfs(i+1,flag) dfs(i+1,flag|2**i) else: num=[] start=0 for i in range(len(n)): if flag&2**i>0: num.append(n[start:i+1]) start=i+1 ans+=sum(num) dfs(0,0) print(ans)
s516481965
p03999
u706695185
1553730946
Python
Python (3.4.3)
py
Runtime Error
31
3436
528
s = list(map(int,list(input()))) if len(s) == 1: print(s[0]) exit(1) from collections import deque cands=deque([[0],[1]]) while len(cands[0]) != len(s)-1: newcands = [] for cand in cands: newcands.append(cand+[0]) newcands.append(cand+[1]) cands = newcands memo = [] while cands: pos = cands.pop() siki = '' for i, p in enumerate(pos): siki += str(s[i]) if p == 1: siki += '+' siki += str(s[-1]) memo.append(eval(siki)) print(sum(memo))
s373822142
p03999
u026155812
1551230517
Python
Python (3.4.3)
py
Runtime Error
26
3064
345
import sys S = input() if len(S) == 1: print(int(S)) sys.exit() ls = [] a = [0, 1] for i in itertools.product(a, repeat=len(S)-1): ans = 0 start = 0 for j, x in enumerate(i): if x == 1: ans += int(S[start:j+1]) start = j + 1 ans += int(S[start:len(S)]) ls.append(ans) print(sum(ls))
s393536443
p03999
u887207211
1550977529
Python
Python (3.4.3)
py
Runtime Error
21
3188
220
S = list(input()) cnt = 0 for i in range(1 << len(S)-1): f = S[0] for j, b in enumerate(format(i, 'b').zfill(len(S)-1)): if(b == '1'): f += '+' f += S[j+1] cnt += sum(map(int,f.split('+'))) print(cnt)
s489666007
p03999
u219607170
1549188428
Python
Python (3.4.3)
py
Runtime Error
19
3064
308
from sys import setrecursionlimit; setrecursionlimit(10**9) S = input() def res(S, A, B): if not S: B.append(sum(list(map(int, A)))) return None A += [S[0]] res(S[1:], A, B) A.pop() A[-1] += S[0] res(S[1:], A, B) return B B = res(S[1:], [S[0]], []) print(sum(B))
s969819657
p03999
u219607170
1549188385
Python
Python (3.4.3)
py
Runtime Error
19
3064
248
S = input() def res(S, A, B): if not S: B.append(sum(list(map(int, A)))) return None A += [S[0]] res(S[1:], A, B) A.pop() A[-1] += S[0] res(S[1:], A, B) return B B = res(S[1:], [S[0]], []) print(sum(B))
s833378548
p03999
u079644963
1546911020
Python
Python (3.4.3)
py
Runtime Error
17
3064
344
a = input() ar = [] for i in range(3): ar.append(a[i]) n = len(ar) ret = 0 for i in range(n+1): s = "+" tmp = "" for j in range(n): if (1 & (i >> j)) == 1: tmp += ar[j] tmp += s else: tmp += ar[j] stmp = tmp.split("+") ret += sum(int(k) for k in stmp) print(int(ret))
s569377084
p03999
u079644963
1546910902
Python
Python (3.4.3)
py
Runtime Error
18
3064
340
a = input() ar = [] for i in range(3): ar.append(a[i]) n = len(ar) ret = 0 for i in range(n+1): s = "+" tmp = "" for j in range(n): if (1 & (i >> j)) == 1: tmp += ar[j] tmp += s else: tmp += ar[j] stmp = tmp.split("+") ret += sum(int(k) for k in stmp) print(ret)
s759977900
p03999
u620945921
1546732444
Python
Python (3.4.3)
py
Runtime Error
89
3188
325
n=input() #print(n) mynum=2**(len(n)-1) #print(mynum) data=['','+'] x=['0']*10000 #print(x) for i in range(mynum): y=format(i, 'b') z=y.zfill(len(n)-1) x[i]=n[0] for j in range(len(z)): x[i]+=data[int(z[j])]+n[j+1] # print(x[i]) x=[eval(i) for i in x] print(n if len(n)==1 else sum(x)) #12656242944
s203768949
p03999
u620945921
1546732076
Python
Python (3.4.3)
py
Runtime Error
90
3188
304
n=input() #print(n) mynum=2**(len(n)-1) #print(mynum) data=['','+'] x=['0']*10000 #print(x) for i in range(mynum): y=format(i, 'b') z=y.zfill(len(n)-1) x[i]=n[0] for j in range(len(z)): x[i]+=data[int(z[j])]+n[j+1] # print(x[i]) x=[eval(i) for i in x] print(sum(x)) #12656242944
s798251516
p03999
u620945921
1546727433
Python
Python (3.4.3)
py
Runtime Error
87
3188
796
n=input() #print(n) data=['','+'] x=['0']*10000 #print(x) for i8 in range(2): for i7 in range(2): for i6 in range(2): for i5 in range(2): for i4 in range(2): for i3 in range(2): for i2 in range(2): for i1 in range(2): for i0 in range(2): x[i0+2*i1+4*i2+8*i3+16*i4+32*i5+64*i6+128*i7+256*i8]=(n[0]+data[i0]+n[1] +data[i1]+n[2] +data[i2]+n[3] +data[i3]+n[4] +data[i4]+n[5] +data[i5]+n[6] +data[i6]+n[7] +data[i7]+n[8] +data[i8]+n[9]) x=[eval(i) for i in x] print(sum(x)) #12656242944
s769786240
p03999
u886274153
1546091603
Python
Python (3.4.3)
py
Runtime Error
18
2940
226
s = input() slen = len(s) kotae = 0 for i in range(2**(slen-1)): for j in range(slen-1): if i & 1<<j: si = si[:slen-j]+"+"+si[slen-j:] else: pass kotae += eval(si) print(kotae)
s313849792
p03999
u983918956
1545636709
Python
Python (3.4.3)
py
Runtime Error
24
3064
741
s = input() l = [s[0]] d = len(s) - 1 def operate_1(string): return string def operate_2(string): string += "+" return string # l,d は未定義注意 def bfs(list_hoge = l,depth = 0,deepest = d): queue = [] for e in list_hoge: for b in [0,1]: if b == 0: operated = operate_1(e) operated += s[depth + 1] queue.append(operated) elif b == 1: operated = operate_2(e) operated += s[depth + 1] queue.append(operated) list_hoge = queue[:] depth += 1 if depth == deepest: return list_hoge else: return bfs(list_hoge,depth) ans = 0 for e in bfs(): ans += eval(e) print(ans)
s343779629
p03999
u136869985
1542568202
Python
Python (3.4.3)
py
Runtime Error
19
3060
222
s = input() ans = 0 for i in range((len(s) - 1) ** 2): tmp = '' for j in range(len(s)): tmp += s[j] if i >> j & 1 == 1: tmp += '+' else: ans += eval(tmp) else: print(ans)
s487225982
p03999
u136869985
1542568127
Python
Python (3.4.3)
py
Runtime Error
18
3064
217
s = input() ans = 0 for i in range((len(s) - 1) ** 2): tmp = '' for j in range(len(s)): tmp += s[j] if i >> j & 1: tmp += '+' else: ans += eval(tmp) else: print(ans)
s638308110
p03999
u263933075
1541261953
Python
Python (3.4.3)
py
Runtime Error
17
2940
194
ss=input() ans=0 for i in range(2**(len(ss)-1)): temp=ss[0] for j in range(len(ss)-1): if i&(1<<j)!=0: temp+="+" temp+=ss[j+1] ans+=eval(temp) print(ans)
s844439504
p03999
u177040005
1539561699
Python
Python (3.4.3)
py
Runtime Error
20
3064
422
S = input() ans = 0 N = 2**(len(S) - 1) for i in range(N): bit = bin(i)[2:] if len(bit) != len(S): bit = '0'*(len(S)-len(bit) - 1) + bit tmp = S[0] # print(bit) for i,b in enumerate(bit): if b == '0': tmp += S[i+1] else: ans += int(tmp) tmp = S[i+1] # tmp += '+' + S[i+1] if len(tmp) > 0: ans += int(tmp) print(ans)
s218468018
p03999
u102126195
1537020426
Python
Python (3.4.3)
py
Runtime Error
24
3444
519
def make(x): x = bin(x)[2:] while len(x) < len(S) - 1: x = "0" + x return list(x) S = input() a = pow(2, len(S) - 1) b = [] for i in range(0, a): b.append(make(i)) i = 0 j = 0 key = int(S[0]) snum = 1 ans = 0 for i in b: snum = 1 key = int(S[0]) for j in i: if j == "0": key *= 10 key += int(S[snum]) elif j == "1": ans += key key = int(S[snum]) #print(i, j, key) snum += 1 ans += key print(ans)
s302490203
p03999
u787562674
1536375429
Python
Python (3.4.3)
py
Runtime Error
17
3064
432
S = input() ans = 0 count_list = [[2 ** (len(S)-1)]] for i in range(1, len(S)): if i == 1: count_list.append([2 ** (len(S)-2), 2 ** (len(S)-2)]) else: count_list.append([*count_list[i-1][:i-1], count_list[i-1][-1]//2, count_list[i-1][-1]//2]) count_list = count_list[::-1] for i in range(len(S)): flag = 1 for j in count_list[i]: ans += int(S[i]) * flag * j flag *= 10 print(ans)
s519833340
p03999
u787562674
1536375379
Python
Python (3.4.3)
py
Runtime Error
17
3064
432
S = input() ans = 0 count_list = [[2 ** (len(S)-1)]] for i in range(1, len(S)): if i == 1: count_list.append([2 ** (len(S)-2), 2 ** (len(S)-2)]) else: count_list.append([*count_list[i-1][:i-1], count_list[i-1][-1]//2, count_list[i-1][-1]//2]) count_list = count_list[::-1] for i in range(len(S)): flag = 1 for j in count_list[i]: ans += int(S[i]) * flag * j flag *= 10 print(ans)
s581639165
p03999
u073775598
1534697508
Python
Python (3.4.3)
py
Runtime Error
17
3064
429
S=str(input()) formula=[""]*(len(S)*2-1) ans=0 for i in range(len(S)*2-1): if i%2==0: formula[i]=S[i//2] place=pow(2,len(S)-1)-1 for i in range(place+1): for j in range(len(bin(i))-2): #strしたbinには0bのprefixが付く。 if int(str(bin(i))[-j-1])==1: formula[2*j+1]="+" ans+=eval(''.join(formula)) for k in range((len(formula)-1)/2): formula[2*k+1]="" print(ans)
s315584098
p03999
u073775598
1534697329
Python
Python (3.4.3)
py
Runtime Error
28
3064
424
S=str(input()) formula=[""]*(len(S)*2-1) ans=0 for i in range(len(S)*2-1): if i%2==0: formula[i]=S[i//2] place=pow(2,len(S)-1)-1 for i in range(place+1): for j in range(len(bin(i))-2): #strしたbinには0bのprefixが付く。 if int(str(bin(i))[-j-1])==1: formula[2*j+1]="+" ans+=eval(''.join(formula)) for k in range(len(bin(i))-2): formula[2*k+1]="" print(ans)
s572850320
p03999
u073775598
1534696885
Python
Python (3.4.3)
py
Runtime Error
30
3064
424
S=str(input()) formula=[""]*(len(S)*2-1) ans=0 for i in range(len(S)*2-1): if i%2==0: formula[i]=S[i//2] place=pow(2,len(S)-1)-1 for i in range(place+1): for j in range(len(bin(i))-2): #strしたbinには0bのprefixが付く。 if int(str(bin(i))[-j-1])==1: formula[2*j+1]="+" ans+=eval(''.join(formula)) for k in range(len(bin(i))-2): formula[2*j+1]="" print(ans)
s325315019
p03999
u118605645
1531879987
Python
Python (3.4.3)
py
Runtime Error
30
3188
445
S = input() # 2^n-1の2進数は全組み合わせを表す combs = pow(2, len(S) - 1) total = 0 for i in range(combs): # i番目の組み合わせ(2進数) comb_i = format(i, '0' + str(len(S)) + 'b') if len(comb_i) > 1: comb_i = comb_i[1:] tmp = S[0] for j in range(len(comb_i)): b = int(comb_i[j]) if b == 1: tmp += "+" tmp += S[j + 1] total += eval(tmp) print(total)
s553332644
p03999
u503901534
1526621133
Python
Python (3.4.3)
py
Runtime Error
18
3064
569
n = int(input()) s = n a = int(input()) b = int(input()) c = int(input()) count = 0 ng = [a,b,c] flag = 0 while count < 100 and n != (a or b or c) and n >=4: if not (n-3 in ng): count += 1 n = n-3 elif not (n-2 in ng): count += 1 n = n-2 elif not (n-1 in ng): count += 1 n = n-1 else: flag = 0 break if (n == 1 or n == 2 or n ==3) and count<=99 and (n not in ng): n = 0 if n > 0: flag = 0 if (flag == 1 or n == 0) and not (s in ng): print('YES') else: print('NO')
s516623093
p03999
u863370423
1524871101
Python
Python (3.4.3)
py
Runtime Error
73
3952
484
memo = [0,0,[[10,1], [1,1]]] def lis(n): if len(memo) == n+1: return memo[n] else: l = lis(n-1) for i in range(len(l)): for j in range(len(l[i])): l[i][j] *= 10 l[i].append(1) l.append([1 for i in range(len(l[0]))]) memo.append(l) return memo[n] s = input() li = lis(len(s)) sum = 0 for i in range(len(li)): for j in range(len(li[i])): sum += int(s[i])*li[i][j] print(sum)
s506477608
p03999
u353919145
1524870987
Python
Python (3.4.3)
py
Runtime Error
72
3956
424
def lis(n): if n == 2: return [[10,1], [1,1]] else: l = lis(n-1) for i in range(len(l)): for j in range(len(l[i])): l[i][j] *= 10 l[i].append(1) l.append([1 for i in range(len(l[0]))]) return l s = input() li = lis(len(s)) sum = 0 for i in range(len(li)): for j in range(len(li[i])): sum += int(s[i])*li[i][j] print(sum)
s804145273
p03999
u583010173
1523102759
Python
Python (3.4.3)
py
Runtime Error
23
3064
862
# -*- coding: utf-8 -*- s = input() bitlist = [] #文字列の長さ-1箇所にプラスを入れるかどうかbit演算によって考える for i in range(2**(len(s)-1)): bitlist.append([int(x) for x in list(bin(i)[2::].zfill(len(s)-1))]) #print(bitlist) total = 0 for bit in bitlist: befnum = int(s[0]) #print(bit) for i, plus in enumerate(bit): if plus == 0: #プラスが入らない場合、前のケタの数を10倍して加える befnum = befnum*10 + int(s[i+1]) #print(befnum) else:#plus==1 #プラスが入る場合、そこまでの数をtotalに加えてbefnumを初期化 total += befnum befnum = int(s[i+1]) #print(befnum) if i == len(bit)-1: total += befnum #print('total:' + str(total)) print(total)
s557475076
p03999
u030726788
1520603028
Python
Python (3.4.3)
py
Runtime Error
27
3060
202
s=input() su=0 for i in range(2**(len(s)-1)): b=bin(i)[2:].zfill(len(s)-1) calcs=s[0] for j in range(len(b)): if(b[j]=="0"):calcs+=s[j+1] else:calcs+="+"+s[j+1] su+=eval(calcs) print(su)
s700470810
p03999
u030726788
1520602999
Python
Python (3.4.3)
py
Runtime Error
17
3064
204
s=input() su=0 for i in range(2**(len(s)-1)): b=bin(i)[2:].zfill(len(s)-1) calcs=s[0] for j in range(len(b)): if(b[j]=="0"):calcs+=s[j+1] else:calcs+="+"+s[j+1] sum+=eval(calcs) print(sum)
s207318713
p03999
u143492911
1519939939
Python
Python (3.4.3)
py
Runtime Error
17
2940
153
s=input() count=0 for i in range(1<<len(s)-1): t="" for j s: if i%2==1: t+="+" i//=2 count+=eval(t) print(count)
s003593049
p03999
u136869985
1519787362
Python
Python (3.4.3)
py
Runtime Error
19
3064
318
def main(): s = input() ans = 0 for i in range((len(s) - 1) ** 2): tmp = "" for j in range(len(s)): tmp += s[j] if (i >> j) & 1: tmp += "+" else: ans += eval(tmp) else: print(ans) if __name__ == "__main__": main()