結果
問題 |
No.2086 A+B問題
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:15:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 35 ms / 2,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 144 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 54,000 KB |
最終ジャッジ日時 | 2025-03-20 21:16:26 |
合計ジャッジ時間 | 1,492 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
a = input().strip() b = input().strip() a_rev = a[::-1] b_rev = b[::-1] max_len = max(len(a_rev), len(b_rev)) carry = 0 result = [] for i in range(max_len): digit_a = int(a_rev[i]) if i < len(a_rev) else 0 digit_b = int(b_rev[i]) if i < len(b_rev) else 0 total = digit_a + digit_b + carry carry = total // 10 result.append(total % 10) if carry > 0: result.append(carry) # Reverse to get the correct order and remove any trailing zeros (though sum won't have leading zeros except when 0) result.reverse() # Handle the case where the result is zero (to avoid empty string) sum_str = ''.join(map(str, result)) print(sum_str)