結果

問題 No.2086 A+B問題
ユーザー lloyzlloyz
提出日時 2022-09-30 21:38:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 542 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 7,916 KB
最終ジャッジ日時 2023-08-24 15:01:21
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 16 ms
7,792 KB
testcase_02 AC 16 ms
7,772 KB
testcase_03 AC 16 ms
7,824 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 15 ms
7,768 KB
testcase_06 AC 15 ms
7,776 KB
testcase_07 AC 15 ms
7,812 KB
testcase_08 AC 15 ms
7,888 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 16 ms
7,912 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 16 ms
7,732 KB
testcase_16 AC 15 ms
7,768 KB
testcase_17 AC 16 ms
7,824 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
7,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A = list(map(int, list(input())))
B = list(map(int, list(input())))

A.reverse()
B.reverse()
n = len(A)
m = len(B)
ANS = [0 for _ in range(max(n, m))]
for i in range(max(n, m)):
    if i < min(n, m):
        ANS[i] = A[i] + B[i]
    else:
        if max(n, m) == n:
            ANS[i] = A[i]
        else:
            ANS[i] = B[i]
    if ANS[i] >= 10:
        if i < max(n, m) - 1:
            ANS[i + 1] += 1
            ANS[i] = ANS[i] % 10
if ANS[-1] >= 10:
    ANS[-1] %= 10
    ANS.append(1)
ANS.reverse()
print(''.join(map(str, ANS)))
0