結果

問題 No.2086 A+B問題
ユーザー lloyzlloyz
提出日時 2022-09-30 21:26:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 554 bytes
コンパイル時間 835 ms
コンパイル使用メモリ 10,924 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2023-08-24 14:39:06
合計ジャッジ時間 1,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,760 KB
testcase_01 AC 15 ms
7,820 KB
testcase_02 AC 15 ms
7,860 KB
testcase_03 AC 15 ms
7,920 KB
testcase_04 AC 15 ms
7,788 KB
testcase_05 AC 16 ms
7,912 KB
testcase_06 AC 15 ms
7,868 KB
testcase_07 AC 16 ms
7,708 KB
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 15 ms
7,844 KB
testcase_12 WA -
testcase_13 RE -
testcase_14 WA -
testcase_15 AC 15 ms
7,820 KB
testcase_16 AC 16 ms
7,708 KB
testcase_17 AC 16 ms
7,760 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 15 ms
7,784 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]
        if ANS[i] >= 10:
            if i < max(n, m):
                ANS[i + 1] += 1
                ANS[i] = ANS[i] % 10
    else:
        if max(n, m) == n:
            ANS[i] = A[i]
        else:
            ANS[i] = B[i]
if ANS[-1] >= 10:
    ANS[-1] %= 10
    ANS.append(1)
ANS.reverse()
print(''.join(map(str, ANS)))
0