⌨️
[AtCoder]ABC-045|C - たくさんの数式
設問ページ
提出結果
import itertools
def getString():
return input()
def main():
S = list(getString())
T = [i for i in range(len(S) - 1)]
m = 0
for i in range(len(T)):
# `+`の入る位置を組み合わせで求める
for t in list(itertools.combinations(T, i + 1)):
n = 0
for j in range(len(S)):
# `+`に出会うまで桁繰り上げ
n = n * 10 + int(S[j])
if j in t:
m += n
n = 0
m += n
m += int("".join(S))
print(m)
if __name__ == "__main__":
main()
Discussion