結果

問題 No.2086 A+B問題
ユーザー tobusakanatobusakana
提出日時 2022-10-16 23:38:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 389 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 86,836 KB
実行使用メモリ 71,556 KB
最終ジャッジ日時 2023-09-10 00:42:05
合計ジャッジ時間 3,454 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,308 KB
testcase_01 AC 73 ms
71,396 KB
testcase_02 AC 73 ms
71,300 KB
testcase_03 AC 73 ms
71,280 KB
testcase_04 AC 74 ms
71,556 KB
testcase_05 AC 75 ms
71,536 KB
testcase_06 AC 75 ms
71,172 KB
testcase_07 AC 73 ms
71,212 KB
testcase_08 AC 75 ms
71,552 KB
testcase_09 AC 73 ms
71,208 KB
testcase_10 AC 73 ms
71,292 KB
testcase_11 AC 75 ms
71,296 KB
testcase_12 AC 75 ms
71,348 KB
testcase_13 AC 72 ms
71,340 KB
testcase_14 AC 75 ms
71,376 KB
testcase_15 AC 75 ms
71,188 KB
testcase_16 AC 72 ms
71,272 KB
testcase_17 AC 73 ms
71,296 KB
testcase_18 AC 74 ms
71,416 KB
testcase_19 AC 74 ms
71,228 KB
testcase_20 AC 73 ms
71,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A = input()
B = input()
D = max(len(A),len(B)) + 1

A = ([0] * (D - len(A)) + list(map(int,list(A))))[::-1]
B = ([0] * (D - len(B)) + list(map(int,list(B))))[::-1]

ans = [0] * D
for i in range(D - 1):
    ans[i] += A[i] + B[i]
    if ans[i] > 9:
        ans[i + 1] += 1
        ans[i] %= 10

a = []
for i in range(D - 1, -1, -1):
    a.append(str(ans[i]))
    
print(int("".join(a)))
    
0