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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
s686970673 | p04001 | u112315075 | 1588215026 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 365 | import sys
S = list(map(int, sys.stdin.readline()))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
sum_ = S[len_S - 1]
cursor = len_S - 1
power = 0
pattern = i
while cursor > 0:
cursor -= 1
if pattern % 2 == 1:
power += 1
else:
power = 0
sum_ += S[cursor] * (10 ** power)
pattern //= 2
ans += sum_
print(ans)
|
s029587544 | p04001 | u112315075 | 1588214372 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 365 | import sys
S = list(map(int, sys.stdin.readline()))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
sum_ = S[len_S - 1]
cursor = len_S - 1
power = 0
pattern = i
while cursor > 0:
cursor -= 1
if pattern % 2 == 1:
power += 1
else:
power = 0
sum_ += S[cursor] * (10 ** power)
pattern >>= 1
ans += sum_
print(ans)
|
s043977446 | p04001 | u112315075 | 1588213771 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 356 | import sys
S = list(map(int, list(sys.stdin.readline())))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
sum_ = S[len_S - 1]
cursor = len_S - 1
power = 0
while cursor > 0:
cursor -= 1
if i % 2 == 1:
power += 1
else:
power = 0
sum_ += S[cursor] * (10 ** power)
i >>= 1
ans += sum_
print(ans)
|
s544840277 | p04001 | u112315075 | 1588213609 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 350 | import sys
S = list(map(int, sys.stdin.readline()))
len_S = len(S)
ans = 0
for i in range(2 ** (len_S - 1)):
sum_ = S[len_S - 1]
cursor = len_S - 1
power = 0
while cursor > 0:
cursor -= 1
if i % 2 == 1:
power += 1
else:
power = 0
sum_ += S[cursor] * (10 ** power)
i >>= 1
ans += sum_
print(ans)
|
s227621000 | p04001 | u344065503 | 1588193881 | Python | PyPy3 (2.4.0) | py | Runtime Error | 166 | 38256 | 165 | 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])
s= input()
n=len(s)
print(dfs(0,s[0]))
|
s845162495 | p04001 | u892487306 | 1588081275 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 680 | S = input()
N = len(S)
plus_flag = [0] * (N - 1)
def calc(flags):
val = 0
num_begin_index = 0
num_end_index = None
for flag_index in range(len(flags)):
if flags[flag_index] == 0:
continue
num_end_index = flag_index + 1
val += int(S[num_begin_index:num_end_index])
num_begin_index = num_end_index
num_end_index = len(flags) + 1
val += int(S[num_begin_index:num_end_index])
return val
def calc_sum(index, flag):
plus_flag[index] = flag
if index == len(plus_flag) - 1:
return calc(plus_flag)
return calc_sum(index + 1, 0) + calc_sum(index + 1, 1)
print(calc_sum(0, 0) + calc_sum(0, 1)) |
s208453955 | p04001 | u114099505 | 1587950876 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 162 | def dfs(i,Str):
if i==n:
return sum(map(int,Str.split()))
return dfs(i+1,Str+S[i+1])+dfs(i+1,Str+"+"+S[i+1])
S=input()
n=len(S)
print(dfs(0,S[0])) |
s011526464 | p04001 | u749071216 | 1587649074 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 833 | import itertools
import math
n=str(input())
s=list(n)
#print(s)
data=[i for i in range(len(n)-1)]
print(data)
combi=list(itertools.product(data, repeat=2))
#print(combi)
#print(type(combi))
data_r = ["+" if i == 1 else i for i in data]
data_r2 = ["" if i == 0 else i for i in data_r]
#print(data_r2)
combi_r2=list(itertools.product(data_r2, repeat=2))
#print(combi_r2)
#print(type(combi_r2))
gokei=0
for i in range(len(combi_r2)):
sushiki=""
for j in range(len(list(n))-1):
sushiki=sushiki+s[j]+combi_r2[i][j]
#print(s[j])
sushiki=sushiki+s[-1]
#print(sushiki)
#print("_",combi_r2[i][0],"_",combi_r2[i][1],"_")
bun=sushiki.split("+")
bun_int = [int(n) for n in bun]
ans=sum(bun_int)
#print(bun_int)
#print(ans)
gokei=gokei+ans
#print("============")
print(gokei) |
s493060595 | p04001 | u130203301 | 1587540707 | Python | PyPy3 (2.4.0) | py | Runtime Error | 182 | 38256 | 303 |
def fun(s):
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):
print(1 << i)
f += "+"
f += s[i+1]
ans += sum(map(int, f.split('+')))
return ans
print(fun(s)) |
s840134770 | p04001 | u411858517 | 1587493958 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1108 | import itertools
def solve(S):
'''
数字の間に+を入れるパターンと入れないパターンを全てチェックする
125であれば、 125, 1+25, 12+5, 1+2+5
+が入る可能性のある場所は右の通り、 1 |ここ!| 2 |ここ!| 5
よって、組み合わせは 2 ** (文字列数 - 1)
'''
count = 0
bit_list = list(itertools.product([0, 1], repeat=len(S)-1))
for pattern in bit_list:
'''
ビットの値が1の時に+が入ると考えて、0の時は入らない
文字列を先頭から調べていき、次の文字との間に+が入る場合、そこまでの文字列をint型に変換して変数「count」に加算する
'''
start = 0
for end in range(len(pattern)):
if pattern[end] == 1:
count += int(S[start:end+1])
start = end + 1
if end == len(bit) - 1:
count += int(S[start:])
print(count)
if __name__ == '__main__':
S = input()
solve(S) |
s379777195 | p04001 | u263753244 | 1587413673 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 531 | print(l)
indexes=[[] for _ in range(2**(n-1))]
for k in range(2**(n-1)):
indexes[k]=[i for i, x in enumerate(l[k]) if x == 1]
#print(indexes)
SUM=0
for j in range(2**(n-1)):
L=len(indexes[j])
if L==0:
SUM+=int(s)
#print(SUM)
else:
SUM+=int(s[:indexes[j][0]+1])
#print(SUM)
SUM+=int(s[indexes[j][L-1]+1:])
#print(SUM)
if L>1:
for h in range(L-1):
SUM+=int(s[indexes[j][h]+1:indexes[j][h+1]+1])
#print(SUM)
print(SUM) |
s776511816 | p04001 | u884601206 | 1586917986 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 465 | s=input()
t=len(s)-1
sl=[s[i] for i in range(len(s))]
answers=[]
for i in range(2**t):
tmp=[]
for j in range(t):
if (i>>j)&1:
tmp.append(j)
ll=['*'] * len(s)
for k in tmp:
ll[k]="+"
ans=[]
for k,_in zip(sl,ll):
ans.append(k)
ans.append(_)
ans=[_ for _ in ans if _ != "*"]
ans=''.join(ans)
ans=ans.split('+')
ans=[int(k) for k in ans if k != '+']
ans=sum(ans)
answers.append(ans)
print(sum(answers))
|
s988880783 | p04001 | u884601206 | 1586917925 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 470 | s=str(input())
t=len(s)-1
sl=[s[i] for i in range(len(S))]
answers=[]
for i in range(2**t):
tmp=[]
for j in range(t):
if (i>>j)&1:
tmp.append(j)
ll=['*'] * len(s)
for k in tmp:
ll[k]="+"
ans=[]
for k,_in zip(sl,ll):
ans.append(k)
ans.append(_)
ans=[_ for _ in ans if _ != "*"]
ans=''.join(ans)
ans=ans.split('+')
ans=[int(k) for k in ans if k != '+']
ans=sum(ans)
answers.append(ans)
print(sum(answers))
|
s888010542 | p04001 | u875449556 | 1586708522 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 219 | S = input()
x = len(S)-1
s = 0
for i in range(1 << x):
t = 0
for j in range(x):
if ((i >> j) & 1 == 1):
s += int(''.join(s[t:j+1]))
t = j+1
s += int(''.join(s[t:]))
print(s) |
s229170412 | p04001 | u875449556 | 1586708485 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 218 | S = input()
x = len(S)-1
s = 0
for i in range(1 << x):
t = 0
for j in range(x):
if ((i >> j) & 1 == 1):
s += int(''.join(s[t:j+1]))
t = j+1
s = int(''.join(s[t:]))
print(s) |
s384895029 | p04001 | u875449556 | 1586665690 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 198 | S = input()
x = len(S)-1
a = 0
b = 0
s = 0
for i in range(1 << x):
for j in range(x):
if ((i >> j) & 1 == 1):
b = j
s += int(S[a:b])
a = j
print(s) |
s830196095 | p04001 | u674959776 | 1586581470 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 163 | s=int(input())
n=len(s)
sum=0
for i in range(1<<n-1):
t=0
for j in range(n-1):
if i & (1<<j):
sum += int("".join(s[t:j+1]))
t = j+1
print(sum) |
s369928477 | p04001 | u673361376 | 1586154825 | Python | PyPy3 (2.4.0) | py | Runtime Error | 192 | 38896 | 274 | S = input()
N = len(S)
ans = 0
for i in range(2 ** (N - 1)):
signs = bin(i)[2:].zfill(N - 1).replace('0', '+').replace('1', ' ')
tmp_s = S[0]
for j, sign in enumerate(signs):
tmp_s += sign + S[j + 1]
ans += eval(tmp_s.replace(' ', ''))
print(ans)
|
s321282906 | p04001 | u538808095 | 1585881314 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 667 | S = input()
n = len(S)
S_list = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]
#1... - 0...+
def bit_to_notation(bit):
bitlist = [0 for i in range(n-1)]
for i in range(n-1):
if ((bit >> i) == 1):
bitlist[n-2-i] = "-"
else:
bitlist[n-2-i] = "+"
return bitlist
notation = 2 ** (n-1)
for bit in range(notation):
sum4 = 0
for j in range(n):
if((bit >> j) & 1):
sum4 -= S_list[n-1-j]
else:
sum4 += S_list[n-1-j]
if(sum4 == 7):
bitlist = bit_to_notation(bit)
print(str(S_list[0]) + bitlist[0] + str(S_list[1]) + bitlist[1]
+ str(S_list[2]) + bitlist[2] + str(S_list[3]) + "=7)
break |
s884921246 | p04001 | u016881126 | 1585806810 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 642 | import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
S_int = int(readline())
S_str = str(S_int)
pattern = []
fmt = '0' + str(len(S_str)-1) + 'b'
for i in range(2**(len(S_str)-1)):
pattern.append(format(i, fmt))
answer = 0
for plus_flags in pattern:
tmp = []
tmp_str = S_str[0]
for i, is_plus in enumerate(plus_flags, start=1):
if is_plus == "1":
tmp.append(int(tmp_str))
tmp_str = ""
tmp_str += S_str[i]
if tmp_str:
tmp.append(int(tmp_str))
answer += sum(tmp)
print(answer) |
s165271847 | p04001 | u916069341 | 1584593960 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 13 | total = 0 |
s544892399 | p04001 | u078932560 | 1584394329 | Python | Python (3.4.3) | py | Runtime Error | 122 | 61416 | 372 | import sys
sys.setrecursionlimit(10000)
s = list(input())
n = len(s)-1
ans = 0
def rec(plus):
if len(plus) == n:
global ans
si = s[0]
for i in range(n):
if plus[i] == '-':
si += s[i+1]
else:
ans = ans + int(si)
si = s[i+1]
ans = ans + int(si)
else:
rec(plus+'-')
rec(plus+'+')
rec('-')
rec('+')
print(ans) |
s344816004 | p04001 | u078932560 | 1584394276 | Python | Python (3.4.3) | py | Runtime Error | 78 | 6904 | 371 | import sys
sys.setrecursionlimit(2000)
s = list(input())
n = len(s)-1
ans = 0
def rec(plus):
if len(plus) == n:
global ans
si = s[0]
for i in range(n):
if plus[i] == '-':
si += s[i+1]
else:
ans = ans + int(si)
si = s[i+1]
ans = ans + int(si)
else:
rec(plus+'-')
rec(plus+'+')
rec('-')
rec('+')
print(ans) |
s695710848 | p04001 | u451013395 | 1584357305 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 465 | target=input()
n = len(target)-1
bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
answer = 0
for bits in bit_list:
one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
# ここで1がある場所を取得
start=0
# 街灯の箇所で文字を区切る関数を実装
for index in one_number_indexes:
answer=answer+int(target[start:index+1])
start=index+1
answer=answer+int(target[start:n+1])
print(answer) |
s735265750 | p04001 | u446371873 | 1584153319 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 212 | s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
eval = ''
for j in range(l):
if ((i >> j) & 1):
eval += s[j] + '+'
else:
eval += s[j]
ans += eval(eval) |
s846215152 | p04001 | u446371873 | 1584138957 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 103 | s = input()
ans = 0
for i in range(s):
ans += int(s[0:i]) + int(s[i:len(s)])
ans += int(s)
print(ans) |
s523792607 | p04001 | u451013395 | 1584099972 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 499 | # coding: utf-8
# Your code here!
target=input()
n = len(target)-1
bit_list = [list(f"{i:0{n}b}") for i in range(2**n)]
answer = 0
for bits in bit_list:
one_number_indexes=[i for i, x in enumerate(bits) if x == '1']
# ここで1がある場所を取得
start=0
# 街灯の箇所で文字を区切る関数を実装
for index in one_number_indexes:
answer=answer+int(target[start:index+1])
start=index+1
answer=answer+int(target[start:n+1])
print(answer) |
s076843565 | p04001 | u699458609 | 1583898666 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 550 | #include <bits/stdc++.h>
using namespace std;
int *dec2bin(int decimal, int *binary, size_t size){
for(i=0; decimal>0; i++){
binary[i] = decimal % 2 * pow(10, i);
decimal = decimal / 2;
}
return binary;
}
int main() {
string S;
cin >> S;
int sum = 0;
int num_cases = pow(2, S.size()-1);
vector<int> binary(num_cases);
dec2bin(18, binary, 6);
/*
for(int i=0; i<num_cases; i++){
string str_bin = to_string(dec2bin(i));
for(int j=0; j<S.size(); j++){
}
}*/
cout << "Hello, world!" << endl;
} |
s447367419 | p04001 | u113991073 | 1583876707 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3056 | 186 | _ = "_"
def solve(s):
if _ in s:#in関数
return solve(s.replace(_,"+",1))+solve(s,replace(_,"",1))
else:
return eval(s)
s=_.join(list(input()))
print(solve(s)) |
s853749744 | p04001 | u433195318 | 1583771387 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 2110 | #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;
typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;
const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;4近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:8近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================
int main() {
//==================================
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(30);
//==================================
string S;
cin >> S;
ll ans = 0;
ll size = S.length();
vll N(size);
for (ll i = 0; i < size; i++) {
N[i] = ll(S[i]) - 48;
}
ll time = 0;
for (ll bit = 0; bit < (1<<size-1) ; bit++) {
ll local = 0;
for (ll i = 0; i < size-1; i++) {
local *= 10;
local += N[i];
if ((bit >> (size - 2 - i)) & 1) {
ans += local;
local = 0;
if (i == size - 2) {
ans += local + N[i + 1];
local = 0;
}
}
else {
if (i == size - 2) {
local *= 10;
ans += local + N[i + 1];
local = 0;
}
}
}
time++;
}
if (size == 1) {
cout << S;
return 0;
}
cout << ans << endl;
}
|
s383414696 | p04001 | u492447501 | 1583627845 | Python | Python (3.4.3) | py | Runtime Error | 27 | 3064 | 270 | import sys
S = input()
N = len(S)-1
sum = 0
for i in range(2**N):
op = [""]*(N)
for j in range(N):
if (i>>j)&1:
op[j] = "+"
s = ""
for j in range(N):
s = s + S[j] + op[j]
s = s + S[j]
sum = sum + eval(s)
print(sum) |
s390372689 | p04001 | u891504219 | 1583469539 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 699 | def main():
#import sys
#input = sys.stdin.readline
S = input()
S_list = list(S)
dig = len(S) - 1
insert_plus = format(0,"0"+str(dig)+"b")
insert_plus_max = "1"*len(insert_plus)
s = 0
for i in range(int(insert_plus_max,2)+1):
before = 0
num_list = []
now = format(i,"0"+str(dig)+"b")
for j in range(len(now)):
if now[j] == "1":
num_list.append("".join(S_list[before:int(j)+1]))
before = j+1
if j == len(now)-1:
num_list.append("".join(S_list[before:]))
for num in num_list:
s += int(num)
print(s)
if __name__ == "__main__":
main() |
s616971222 | p04001 | u235783479 | 1583464268 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 500 | s = input()
# print(s)
score = 0
for blocksize in range(1,len(s)+1):
for startpoint in range(len(s)):
# print("hi", startpoint+blocksize)
if startpoint+blocksize >= (len(s)+1): continue
block = s[startpoint:startpoint+blocksize]
ss = int(block) * math.factorial(startpoint) * math.factorial(len(s) - (startpoint+blocksize))
# print("{} ({}, {}): {}".format(block, startpoint, len(s) - (startpoint + blocksize), ss))
score += ss
print(score)
exit() |
s031232088 | p04001 | u540698208 | 1583271141 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 323 | import itertools
s = input()
n = [i for i in s]
ans = 0
for i in range(len(n)):
for j in itertools.combinations(range(len(n)-1, i)):
temp = [i for i in s]
for k in j[::-1]:
temp.insert(k+1, "+")
temp = "".join(temp)
temp = temp.split("+")
temp = map(int, temp)
ans += sum(temp)
print(ans) |
s333587549 | p04001 | u370429695 | 1583252490 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 188 | def dfs(i, sum):
if i == len(s) - 1:
return sum(list(map(int,sum.split("+"))))
return dfs(i+1, sum + s[i+1]) + dfs(i+1, sum + "+" + s[i+1])
s = input()
print(dfs(0,s[0])) |
s905126821 | p04001 | u928784113 | 1582044058 | Python | Python (3.4.3) | py | Runtime Error | 171 | 13704 | 2277 | import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def sieve_of_eratosthenes(n):
if not isinstance(n,int):
raise TypeError("n is not int")
if n<2:
raise ValueError("n is not effective")
prime = [1]*(n+1)
for i in range(2,int(math.sqrt(n))+1):
if prime[i] == 1:
for j in range(2*i,n+1):
if j%i == 0:
prime[j] = 0
res = []
for i in range(2,n+1):
if prime[i] == 1:
res.append(i)
return res
def factorial(i):
if i == 1:
return 1
else:
return i*factorial(i-1)
class UnionFind:
def __init__(self,n):
self.parent = [i for i in range(n+1)]
self.rank = [0 for i in range(n+1)]
def findroot(self,x):
if x == self.parent[x]:
return x
else:
y = self.parent[x]
y = self.findroot(self.parent[x])
return y
def union(self,x,y):
px = self.findroot(x)
py = self.findroot(y)
if px < py:
self.parent[py] = px
else:
self.parent[px] = py
def same_group_or_no(self,x,y):
return self.findroot(x) == self.findroot(y)
def main(): #startline--------------------------------------------
s = input()
sl = [i for i in s]
n = len(s)-1
ans = []
anslist = []
sublist = [-1]*n
for i in range(1 << n):
for j in range(n):
if (i>>j)&1:
sublist[j] = "+"
anslist.append(sl[0])
for j in range(n):
if sublist[j] == "+":
anslist.append("+")
anslist.append(sl[j+1])
else:
anslist.append(sl[j+1])
ans.append(eval("".join(anslist)))
anslist = []
sublist = [-1]*n
print(sum(ans))
if __name__ == "__main__":
main()
#endline===============================================
|
s364272345 | p04001 | u928784113 | 1581527553 | Python | Python (3.4.3) | py | Runtime Error | 38 | 5172 | 2238 | import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(100000)
def sieve_of_eratosthenes(n):
if not isinstance(n,int):
raise TypeError("n is not int")
if n<2:
raise ValueError("n is not effective")
prime = [1]*(n+1)
for i in range(2,int(math.sqrt(n))+1):
if prime[i] == 1:
for j in range(2*i,n+1):
if j%i == 0:
prime[j] = 0
res = []
for i in range(2,n+1):
if prime[i] == 1:
res.append(i)
return res
def factorial(i):
if i == 1:
return 1
else:
return i*factorial(i-1)
class UnionFind:
def __init__(self,n):
self.parent = [i for i in range(n+1)]
self.rank = [0 for i in range(n+1)]
def findroot(self,x):
if x == self.parent[x]:
return x
else:
y = self.parent[x]
y = self.findroot(self.parent[x])
return y
def union(self,x,y):
px = self.findroot(x)
py = self.findroot(y)
if px < py:
self.parent[py] = px
else:
self.parent[px] = py
def same_group_or_no(self,x,y):
return self.findroot(x) == self.findroot(y)
def main(): #startline--------------------------------------------
s = input()
sl = [i for i in s]
n = len(s)-1
sublist = [-1]*n
anslist = []
ans = []
for i in range(1<<n):
for j in range(n):
if (i>>j)&1:
sublist[j] = "+"
anslist.append(sl[0])
for j in range(n):
if sublist[j] == "+":
anslist.append(sublist[j])
anslist.append(sl[j+1])
else:
anslist.append(sl[j+1])
ans.append(eval("".join(anslist)))
anslist = []
sublist = []
print(sum(ans))
if __name__ == "__main__":
main() #endline===============================================
|
s377477182 | p04001 | u150985282 | 1581408583 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 72 | S = input()
[s1, s2] = S.split("+")
[s1, s2] = list(map(int, [s1, s2])) |
s572044718 | p04001 | u381246791 | 1581381392 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 322 | #coding:utf-8
S=input()
n=len(S)-1
answer=0
for i in range(2**n):
formula=list(S)
for j in range(n):
if ((i<<j)&1):
formula=S.insart("+",j+1)
for i,elem in enumerate(formula):
num=""
if elem=="+" or i==len(formula)-1:
answer+=int(num)
num=0
else:
num+=elem
print(answer)
|
s154200070 | p04001 | u232011870 | 1581367643 | Python | Python (3.4.3) | py | Runtime Error | 20 | 3064 | 709 | s=list(input())
n=len(s)
n2 = 2**(n-1)
n3 = (n-1)*-1
# if n2 = 1
ans=0
for i in range(n2):
li = list(format(i,'010b'))
li = li[n3:]
# print(li)
tmpstr=s[0]
tmpnum=0
index = 0
for j in li:
# print("ans",ans,"tmpstr",tmpstr,"tmpnum",tmpnum,"index",index)
if j == '0':
# string
tmpstr=tmpstr+s[index+1]
else:
# plus
if tmpstr =="":
tmpnum=0
else:
tmpnum=int(tmpstr)
tmpstr=s[index+1]
ans=ans+tmpnum
index += 1
if tmpstr != "":
# print("ans",ans,"tmpstr",tmpstr)
tmpnum=int(tmpstr)
ans=ans+tmpnum
print(ans)
|
s824812852 | p04001 | u501451051 | 1581259288 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 221 | S = input()
ans = 0
for i in range(2**(len(S)-1):
temp = S
for j in range(len(S)-1):
if(i >> j) & 1:
temp = temp[:j - len(S) + 1]+'+'+temp[j-len(S)+1:]
ans += eval(temp)
print(ans)
|
s364557668 | p04001 | u103902792 | 1580950480 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 281 | s = input()
n = len(s)
cand = []
def func(ac,yet,sum):
next = int(yet[0])
if len(yet) ==1:
cand.append(sum+ ac+ next)
cand.append(sum+ ac*10+ next)
else:
func(next, yet[1:],ac+sum)
func(ac*10+next, yet[1:],sum)
func(int(s[0]),s[1:],0)
print(sum(cand)) |
s311713800 | p04001 | u103902792 | 1580947277 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 255 | s = input()
n = len(s)
ans = 0
for i in range(2**(n-1)):
form = s
bit = []
for _ in range(n-1):
bit.append(i%2)
i = i//2
for j in range(n):
if bit[j]:
form = form[:n-j] + '+' + form[n-j:]
ans += form.eval()
print(ans) |
s229654685 | p04001 | u840974625 | 1580926617 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 243 | s = input()
n = len(s)
res = 0
def part_sum(cur, i):
if i != n:
res += part_sum(cur+s[i], i+1)
res += part_sum(cur+s[i]+"+", i+1)
else:
cur += s[i]
return sum(list(map(int, cur.split("+"))))
part_sum("", 0)
print(res) |
s338178140 | p04001 | u840974625 | 1580926462 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 229 | s = input()
n = len(s)
res = 0
def part_sum(cur, i):
if i != n:
part_sum(cur+s[i], i+1)
part_sum(cur+s[i]+"+", i+1)
else:
cur += s[i]
res += sum(list(map(int, cur.split("+"))))
part_sum("", 0)
print(res) |
s965140916 | p04001 | u840974625 | 1580926393 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 229 | s = input()
n = len(s)
res = 0
def part_sum(cur, i):
if i != n:
part_sum(cur+s[i], i+1)
part_sum(cur+s[i]+"+", i+1)
else:
cur += s[i]
res += sum(list(map(int, cur.split("+"))))
part_sum([], 0)
print(res) |
s275949815 | p04001 | u840974625 | 1580926218 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 229 | s = input()
n = len(s)
res = 0
def part_sum(cur, i):
if i != n:
part_sum(cur+s[i], i+1)
part_sum(cur+"+"+s[i], i+1)
else:
cur += s[i]
res += sum(list(map(int, res.split("+"))))
part_sum([], 0)
print(res) |
s358215653 | p04001 | u875449556 | 1580765853 | Python | Python (3.4.3) | py | Runtime Error | 35 | 3060 | 216 | S = input()
n = len(S)
e = ""
s = 0
for i in range(2**(n-1)):
for j in range(n-1):
e += S[j]
if (i << j & 1):
e += "+"
s += sum(map(int, e.split("+")))
print(s)
|
s188260296 | p04001 | u375542418 | 1580680782 | Python | Python (3.4.3) | py | Runtime Error | 23 | 3064 | 652 | s = str(input())
s_list = []
for i in range(len(s)):
s_list.append(s[i])
#print(s_list)
L = len(s_list)
sum_a = 0
for k in range(2**(L-1)):
plus_list = [0]*(L-1)
p = list(bin(k)[2:])
for l in range(len(p)):
plus_list[L-len(p)+l-1] = int(p[l])
#print("p_list:",plus_list)
#print("p:",p)
num_list = []
start = 0
for i in range(len(plus_list)):
if plus_list[i]:
num_list.append(s_list[start:i+1])
start = i+1
num_list.append(s_list[start:])
ans = 0
for i in num_list:
s = ''
for j in i:
s = s+j
ans += int(s)
sum_a += ans
#print("num_list:",num_list)
#print("ans:",ans)
print(sum_a) |
s060328042 | p04001 | u408620326 | 1580359036 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3060 | 255 | import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
t = ''
for j in range(n-1):
t += s[j]
if (i >> j) & 1:
t += '+'
else:
t += s[n-1]
ans += eval(t)
print(ans)
|
s380064310 | p04001 | u255382385 | 1580358073 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 281 | s = input()
n = len(s) - 1
sum = 0
if n == 0:
print(s)
return
for bit in range(1 << n):
eval_str = ''
for i in range(n):
eval_str += s[i]
if bit & (1 << i):
eval_str += '+'
eval_str += s[i + 1]
sum += eval(eval_str)
print(sum) |
s580222736 | p04001 | u255382385 | 1580357743 | Python | Python (3.4.3) | py | Runtime Error | 26 | 3060 | 245 | s = input()
n = len(s) - 1
sum = 0
for bit in range(1 << n):
eval_str = ''
for i in range(n):
eval_str += s[i]
if bit & (1 << i):
eval_str += '+'
eval_str += s[i + 1]
sum += eval(eval_str)
print(sum) |
s534885835 | p04001 | u183657342 | 1579994367 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 215 | s = str(input())
ans = 0
for i in 2**(len(s)-1):
x = s[0]
for j in range(len(s)-1):
if (i>>j) & 1:
x += '+'
x += s[j+1]
ans += sum(map(int,x.split('+')))
print(ans) |
s633352290 | p04001 | u193019328 | 1579915329 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 212 | S = 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 << (n-1)):
f += "+"
f += S[i+1]
ans += sum(map(int,f.split("+")
print(ans) |
s300563851 | p04001 | u193019328 | 1579718964 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 140 | a = input()
sum = int(a)
for i in range(len(a)-1):
sum += int(a[i])
sum += int(a[:i+1]) + int(a[i+1:])
sum += int(a[i+1])
print(sum) |
s674017588 | p04001 | u193019328 | 1579714117 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 101 | a = input()
sum = int(a)
for i in range(len(a)-1):
sum += int(a[:i]) + int(a[i+1:])
print(int(sum)) |
s867460227 | p04001 | u134302690 | 1579697371 | Python | Python (3.4.3) | py | Runtime Error | 22 | 3064 | 460 | s=input()
n=len(s)-1
l=[]
for i in range(n):
l.append("+")
sum = 0
for i in range(2 ** n):
plus = []
tmp = ""
ans = 0
for j in range(n):
if ((i>>j) & 1):
plus.append(l[j])
else:
plus.append("")
for i in range(n):
tmp += s[i]+plus[i]
if i == n-1:
tmp+=s[i+1]
tmp2 = tmp.split("+")
for i in range(len(tmp2)):
ans += int(tmp2[i])
sum+=ans
print(sum)
|
s657008413 | p04001 | u932864155 | 1579569931 | Python | Python (3.4.3) | py | Runtime Error | 28 | 3064 | 320 | S = input()
n = len(S)
total = 0
for i in range(2**(n-1)) :
ls = [""] * (n-1)
for j in range(n) :
if ((i >> j) & 1) :
ls[j] = "+"
for k in range(n) :
if k==0 :
fo = S[k] + ls[k]
elif k==n-1 :
fo = fo + S[k]
else :
fo = fo + S[k] + ls[k]
total += eval(fo)
print(total) |
s520278214 | p04001 | u708378905 | 1579314063 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 401 | def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
if len(splitted) == depth:
return a + b
else:
# 左のdfs() 呼び出し -> +を挿入しなかったとき
# 右のdfs() 呼び出し -> +を挿入したとき
return dfs(splitted, a, b * 10, depth + 1) + dfs(splitted, a + b, splitted[i], depth + 1)
s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0)) |
s188802883 | p04001 | u708378905 | 1579313990 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 394 | def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
if len(splitted) == depth:
return a + b
else:
# 左のdfs() 呼び出し -> +を挿入しなかったとき
# 右のdfs() 呼び出し -> +を挿入したとき
return dfs(splitted, a, b * 10, depth + 1) + dfs(s, a + b, splitted[i], depth + 1)
s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0)) |
s067808359 | p04001 | u708378905 | 1579313916 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 394 | def dfs(splitted: "the list of integer", a: int, b: int, depth: int) -> int:
if len(splitted) == depth:
return a + b
else:
# 左のdfs() 呼び出し -> +を挿入しなかったとき
# 右のdfs() 呼び出し -> +を挿入したとき
return dfs(splitted, a, b * 10, depth + 1) + dfs(s, a + b, splitted[i], depth + 1)
s = [int(x) for x in input()]
print(dfs(s, 0, 0, 0)) |
s000330087 | p04001 | u747220349 | 1578790108 | Python | PyPy3 (2.4.0) | py | Runtime Error | 167 | 38640 | 156 | s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n)):
a=s[0]
for i in range(n):
a=a+b[i]+s[i+1]
ans+=eval(a)
print(ans)
|
s153119984 | p04001 | u747220349 | 1578790086 | Python | PyPy3 (2.4.0) | py | Runtime Error | 165 | 38512 | 155 | s=input()
n=len(s)-1
ans=0
for b in list(product(['+',''],repeat=n))
a=s[0]
for i in range(n):
a=a+b[i]+s[i+1]
ans+=eval(a)
print(ans)
|
s169286450 | p04001 | u973744316 | 1578627436 | Python | Python (3.4.3) | py | Runtime Error | 18 | 2940 | 213 | S = int(input())
N = len(S) - 1
ans = 0
for i in range(2 ** N):
k = 0
for j in range(N):
if (i >> j) & 1:
ans += int(S[k:j + 1])
k = j + 1
ans += int(S[k:])
print(ans)
|
s737892492 | p04001 | u973744316 | 1578627412 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 230 | S = int(input())
N = len(S) - 1
ans = 0
for i in range(2 ** N):
k = 0
for j in range(N):
# 復元
if (i >> j) & 1:
ans += int(S[k:j + 1])
k = j + 1
ans += int(S[k:])
print(ans)
|
s137324572 | p04001 | u973744316 | 1578627286 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 230 | S = int(input())
N = len(S) - 1
ans = 0
for i in range(2 ** N):
k = 0
for j in range(N):
# 復元
if (i >> j) & 1:
ans += int(S[k:j + 1])
k = j + 1
ans += int(S[k:])
print(ans)
|
s662881465 | p04001 | u427314356 | 1578074760 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3188 | 194 | n = input()
l = len(n)
ans = 0
for bit in range(1 << l-1):
f = n[0]
for i in range(1<<l):
if bit & i:
f += '+"
f += n[i]
ans += sum([int(x) for x in f.split('+')])
print(ans) |
s294410013 | p04001 | u427314356 | 1578074740 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 194 | n = input()
l = len(n)
ans = 0
for bit in range(1 << l-1):
f = n[0]
for i in range(1<<l):
if bit & i:
f += '+"
f += n[i]
ans += sum([int(x) for x in f.split('+')])
print(ans) |
s101457001 | p04001 | u593567568 | 1576632988 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 487 | import sys
from collections import deque
sys.setrecursionlimit(1000000000)
def dfs(xs,q):
if len(xs) == 0:
return sum(int(i) for i in q)
x = xs.popleft()
if len(q) == 0:
q.append(x)
return dfs(xs,q)
a1 = xs.copy()
a2 = xs.copy()
q1 = q.copy()
q2 = q.copy()
q1.append(x)
y = q2.pop()
yx = y + x
q2.append(yx)
return dfs(a1,q1) + dfs(a2,q2)
s = str(input())
xs = deque(list(s))
print(dfs(xs,deque([]))) |
s421316065 | p04001 | u593567568 | 1576630660 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 402 | import sys
from collections import deque
sys.setrecursionlimit(1000000000)
def dfs(xs):
x = xs.popleft()
if len(xs) == 0:
return x
# not +
xs2 = xs.copy()
y = xs2.popleft()
xy = int(str(x)+str(y))
xs2.appendleft(xy)
b = dfs(xs2)
# has +
a = x + x + dfs(xs)
return a+b
s = str(input())
xs = list(map(int,s))
xs = deque(xs)
print(dfs(xs)) |
s059692996 | p04001 | u593567568 | 1576626722 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 356 | from collections import deque
def dfs(xs):
x = xs.popleft()
if len(xs) == 0:
return x
# not +
xs2 = xs.copy()
y = xs2.popleft()
xy = int(str(x)+str(y))
xs2.appendleft(xy)
b = dfs(xs2)
# has +
a = x * 2 + dfs(xs)
return a+b
s = str(input())
xs = list(map(int,s))
xs = deque(xs)
print(dfs(xs)) |
s134219537 | p04001 | u593567568 | 1576626463 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 375 | from collections import deque
def dfs(xs):
print("xs",xs)
x = xs.popleft()
if len(xs) == 0:
return x
# not +
xs2 = xs.copy()
y = xs2.popleft()
xy = int(str(x)+str(y))
xs2.appendleft(xy)
b = dfs(xs2)
# has +
a = x * 2 + dfs(xs)
return a+b
s = str(input())
xs = list(map(int,s))
xs = deque(xs)
print(dfs(xs)) |
s200235593 | p04001 | u593567568 | 1576625822 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3316 | 353 | from collections import deque
def dfs(xs):
x = xs.popleft()
if len(xs) == 0:
return x
# not +
xs2 = xs.copy()
y = xs2.popleft()
xy = int(str(x)+str(y))
xs2.appendleft(xy)
b = dfs(xs2)
# has +
a = x + dfs(xs)
return a+b
s = str(input())
xs = list(map(int,s))
xs = deque(xs)
print(dfs(xs)) |
s365410534 | p04001 | u521020719 | 1576406744 | Python | PyPy3 (2.4.0) | py | Runtime Error | 357 | 55260 | 242 | def dfs(formula, index):
if index + 1 == max_index:
return sum(list(map(int, formula.split("+"))))
return dfs(formula + "+" + S[index], index + 1) + dfs(formula + S[index], index)
S = input()
max_index = len(S)
dfs(S[0], 0) |
s203029944 | p04001 | u521020719 | 1576406123 | Python | PyPy3 (2.4.0) | py | Runtime Error | 180 | 38256 | 245 | def dfs(i, formula):
if i + 1 == num_digits:
return sum(list(map(int, formula.split("+"))))
return sum(dfs(i + 1, formula + "+" + s[i + 1]), dfs(i + 1, formula + s[i + 1]))
s = input()
num_digits = len(s)
print(dfs(0, s[0]))
|
s606437836 | p04001 | u752907966 | 1576374873 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 444 | 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+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
print(dfs(0,s[0])) |
s773194913 | p04001 | u752907966 | 1576374815 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 443 | 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+2,f+"+"+s[i+1])#+を入れない場合、+をいれる場合
print(dfs(0,s[0]) |
s161721703 | p04001 | u054871430 | 1575829433 | Python | PyPy3 (2.4.0) | py | Runtime Error | 171 | 38384 | 594 | def add_or_do_nothing(s, i, pos):
if i == len(s):
pre_i = 0
ans = 0
for pos_i in pos:
print(s[pre_i:pos_i], pre_i, pos_i)
ans += int(s[pre_i:pos_i])
pre_i = pos_i
if pre_i == 0:
ans = int(s)
else:
ans += int(s[pre_i:len(s)] if pre_i != len(s) else '0')
return ans
f_ans = add_or_do_nothing(s, i+1, pos)
pos.append(i)
s_ans = add_or_do_nothing(s, i+1, pos)
return f_ans + s_ans
s = input()
pos = []
ans = add_or_do_nothing(s, 1, pos)
print(ans) |
s826163908 | p04001 | u638282348 | 1575428772 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 191 | nums = list(input().strip())
N = len(nums)
head = nums.pop(0)
print(sum(eval(head + "".join([f"{'' if (j >> i) % 2 else '+'}{n}" for i, n in enumerate(nums)])) for j in range(2 ** (N - 1))))
|
s538367877 | p04001 | u600935366 | 1574484644 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 206 | s = input()
n = len(s)
def dfs(tmp, s):
if len(s) == 1:
return int(tmp)+int(s)+int(tmp+s)
return int(tmp)*2**(len(s)-1)+dfs(s[0], s[1:]) + dfs(tmp+s[0], s[1:])
print(dfs(s[0], s[1:])) |
s601130087 | p04001 | u322229918 | 1574465327 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 396 | s = input()
item = np.arange(len(s) - 1) + 1
n = len(item)
count = 0
for i in range(2 ** n):
sidx = 0
for j in range(n): # このループが一番のポイント
if ((i >> j) & 1): # 順に右にシフトさせ最下位bitのチェックを行う
eidx = item[j]
count += int(s[sidx:eidx])
sidx = eidx
count += int(s[sidx:])
print(count) |
s137182269 | p04001 | u077291787 | 1574090985 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 572 | import sys
input = sys.stdin.readline()
s = input()
n = len(s)
total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り,3文字なら4通り,n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
# iは各桁に+を挿入するかどうかを決定する
# 例えば s=12345, i=0b0111, ss=1+2+3+45
now_sum = 0
reg = int(s[0])
for j in range(n - 1):
if i & 1 << j:
now_sum += reg
reg = 0
reg *= 10
reg += int(s[j + 1])
now_sum += reg
total_sum += now_sum
print(total_sum)
|
s281925188 | p04001 | u076506345 | 1574089479 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3060 | 574 | import sys
input = sys.stdin.readline
s = input()
n = len(s)
total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り,3文字なら4通り,n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
# iは各桁に+を挿入するかどうかを決定する
# 例えば s=12345, i=0b0111, ss=1+2+3+45
now_sum = 0
reg = int(s[0])
for j in range(n - 1):
if i & 1 << j:
now_sum += reg
reg = 0
reg *= 10
reg += int(s[j + 1])
now_sum += reg
total_sum += now_sum
print(total_sum)
|
s328433310 | p04001 | u076506345 | 1574089284 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 574 | import sys
input = sys.stdin.readline
s = input()
n = len(s)
total_sum = 0
# +を挿入する事象は
# sが2文字なら2通り,3文字なら4通り,n文字なら2^(n-1)通りある
for i in range(2 ** (n - 1)):
# iは各桁に+を挿入するかどうかを決定する
# 例えば s=12345, i=0b0111, ss=1+2+3+45
now_sum = 0
reg = int(s[0])
for j in range(n - 1):
if i & 1 << j:
now_sum += reg
reg = 0
reg *= 10
reg += int(s[j + 1])
now_sum += reg
total_sum += now_sum
print(total_sum)
|
s447052795 | p04001 | u521020719 | 1574069655 | Python | PyPy3 (2.4.0) | py | Runtime Error | 170 | 38384 | 219 | number = int(input())
num_digits = len(str(number))
def dfs(i, sum_number):
if i == num_digits:
return sum_number
dfs(i + 1, sum_number)
dfs(i + 1, sum_number + str(number)[i])
print(dfs(0, 0))
|
s859477309 | p04001 | u609061751 | 1573031264 | Python | Python (3.4.3) | py | Runtime Error | 24 | 3064 | 242 | S = input()
s = S[0]
ans = 0
def dfs(n,S,s):
global ans
s_0 = s + "+" + S[n]
s_1 = s + S[n]
if n == len(S) - 1:
ans += eval(s_0) + eval(s_1)
else:
dfs(n+1,S,s_0)
dfs(n+1,S,s_1)
dfs(1,S,s)
print(ans) |
s250306601 | p04001 | u557494880 | 1572825148 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 194 | S = intinput()
n = len(S)
ans = 0
for i in range(2**(n-1)):
s = S[0]
for j in range(n-1):
if (i >> j) & 1:
s += '+'
s += S[j+1]
ans += eval(s)
print(ans)
|
s970170521 | p04001 | u557494880 | 1572825074 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3060 | 195 | S = int(input())
n = len(S)
ans = 0
for i in range(2**(n-1)):
s = S[0]
for j in range(n-1):
if (i >> j) & 1:
s += '+'
s += S[j+1]
ans += eval(s)
print(ans) |
s771992693 | p04001 | u557494880 | 1572649085 | Python | Python (3.4.3) | py | Runtime Error | 2120 | 254488 | 611 | S = str(input())
def plus(a,b,c):
x = a[0:b+1] + c + a[b+1:len(a)]
return(x)
A = [S]
while len(A) != 2**(len(S)):
for i in range(len(S)-1):
for j in range(len(A)):
x = A[j]
y = plus(x,i,'+')
A.append(y)
s = 0
for i in range(len(A)):
x = A[i]
p = 0
q = 0
for j in range(len(x)):
if x[j] == '+':
q = j - 1
m = x[p:q]
s += int(m)
p = j + 1
elif j == len(x):
q = len(x)
m = x[p:q]
s += int(m)
print(s)
|
s465837869 | p04001 | u168333670 | 1571014458 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 459 | S = input()
def func(num, code):
total = 0
start = 0
length = len(num)
for i in range(1, length):
if code & 1 == 1: #一番下にビットが立ってるなら
total = total + int(num[start:i])
start = i
code = code >> 1
total = total + int(num[start:i + 1])
return total
total_of_all = 0
for i in range(2 ** (len(S) - 1)):
total_of_all = total_of_all + func(S, i)
print(total_of_all) |
s737262001 | p04001 | u168333670 | 1571014400 | Python | Python (3.4.3) | py | Runtime Error | 21 | 3064 | 481 | S = input()
def func(num, code):
total = 0
start = 0
length = len(num)
for i in range(1, length):
if code & 1 == 1: #一番下にビットが立ってるなら
total = total + int(num[start:i])
start = i
code = code >> 1
total = total + int(num[start:i + 1])
return total
total_of_all = 0
for i in range(2 ** (len(S) - 1)):
print(func(S, i))
total_of_all = total_of_all + func(S, i)
print(total_of_all) |
s521656512 | p04001 | u208497224 | 1570282118 | Python | PyPy3 (2.4.0) | py | Runtime Error | 327 | 46060 | 1406 | import copy
s = input()
def value(s, adding_list):
insert_index = []
for index in range(len(adding_list)):
if adding_list[index]:
insert_index.append(index)
if len(insert_index) == 0:
return int(s)
value_list = []
for index in range(len(insert_index)):
if index == 0:
value_list.append(s[0:insert_index[index]+1])
if index < len(insert_index)-1:
value_list.append(s[(insert_index[index]+1) : insert_index[index+1]+1])
if index == len(insert_index)-1:
value_list.append(s[insert_index[index]+1:])
ret_val = 0
for value in value_list:
ret_val += int(value)
return ret_val
def dfs(adding_list, changing_index):
print(changing_index)
sum = 0
if changing_index == len(s)-2:
return value(s, adding_list)
else:
changing_index += 1
new_adding_list = copy.copy(adding_list)
sum += dfs(new_adding_list, changing_index)
new_adding_list = copy.copy(adding_list)
new_adding_list[changing_index] = True
sum += dfs(new_adding_list, changing_index)
return sum
def main():
ret_val = 0
plus_list = [False for _ in range(len(s)-1)]
ret_val += dfs(plus_list, 0)
plus_list = [False for _ in range(len(s)-1)]
plus_list[0] = True
ret_val += dfs(plus_list, 0)
print(ret_val)
main() |
s924339423 | p04001 | u641851773 | 1569980663 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 1004 | #!/usr/bin/python3
import sys
def dprint(*args):
pass
#print(*args)
def solve(s_str):
ans = 0
s_len = len(s_str)
for bits in range(0, 1 << (s_len - 1)):
dprint("bits: {0:b}".format(bits))
rev_str = list(reversed(s_str))
dprint(f"rev_str: {rev_str}")
cur_num_rev_str = ""
# 12345
for rev_i in range(0, s_len):
dprint("rev_i: %d" % rev_i)
plus_index = rev_i
cur_num_rev_str += rev_str[0]
rev_str = rev_str[1:]
dprint("cur_num_rev_str: %s" % cur_num_rev_str)
if rev_i == s_len - 1 or bits & (1 << plus_index):
ans += int(''.join(list(reversed(cur_num_rev_str))))
cur_num_rev_str = ""
if cur_num_rev_str != "":
dprint(f"ans: {ans}")
ans += int(''.join(list(reversed(cur_num_rev_str))))
return ans
def main():
s_str = sys.stdin.read().rstrip()
dprint(s_str)
print(solve(s_str))
main() |
s895114031 | p04001 | u589047182 | 1569567457 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 197 | 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])s
s = input()
n = len(s)
print(dfs(0, s[0]))
|
s581222233 | p04001 | u420522278 | 1569166194 | Python | Python (3.4.3) | py | Runtime Error | 19 | 3064 | 398 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
S = ns()
s = []
for i in S:
s.append(i)
s.append('')
del s[-1]
out = 0
for i in range(2**(len(S)-1)):
for j in range(1, len(S)):
if (i//(2**(j-1)))%2 == 1:
s[-2*j] = '+'
else:
s[-2*j] = ''
out += eval(''.join(s))
print(out)
|
s290860160 | p04001 | u420522278 | 1569166106 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 411 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
S = ns()
s = []
for i in S:
s.append(i)
s.append('')
del s[-1]
out = 0
for i in range(2**(len(S)-1)):
for j in range(1, len(S)):
if (i//(2**(j-1)))%2 == 1:
s[-2*j] = '+'
else:
s[-2*j] = ''
# print(s)
out += eval(''.join(s))
print(out)
|
s539225372 | p04001 | u420522278 | 1569166005 | Python | Python (3.4.3) | py | Runtime Error | 17 | 3064 | 397 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
S = ns()
s = []
for i in S:
s.append(i)
s.append('')
del s[-1]
out = 0
for i in range(2**(len(S)-1)):
for j in range(1, len(S)):
if (i//(2**(j-1)))%2 == 1:
s[-2*j] = '+'
else:
s[-2*j] = ''
out += eval(''.join(s))
print(out) |
s020651403 | p04001 | u420522278 | 1569165944 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3064 | 410 | import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()
S = ns()
s = []
for i in S:
s.append(i)
s.append('')
del s[-1]
out = 0
for i in range(2**(len(S)-1)):
for j in range(1, len(S)):
if (i//(2**(j-1)))%2 == 1:
s[-2*j] = '+'
else:
s[-2*j] = ''
# print(s)
out += eval(''.join(s))
print(out) |
s627344345 | p04001 | u386170566 | 1568939384 | Python | Python (3.4.3) | py | Runtime Error | 17 | 2940 | 304 | #arc061_C - たくさんの数式 / Many Formulas
s = list(str(input()))
l = len(s)
def dfs(i,f):
if i == l-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])) |
s822601946 | p04001 | u274080981 | 1567508882 | Python | Python (3.4.3) | py | Runtime Error | 18 | 3188 | 356 | d,g=map(int, input().split())
table = []
alscr=0
cnt=0
for i in range(d):
table.append( [(i+1) * 100] + list(map(int,input().split())) )
for i in range(0,d)[::-1]:
scr=table[i][0]
num=table[i][1]
bns=table[i][2]
for i in range(num):
alscr+=scr
cnt +=1
if i == num-1:
alscr += bns
if alscr >= g:
print(cnt)
break |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.