結果
| 問題 |
No.2323 Nafmo、A+Bをする
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-16 21:22:21 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 2,000 ms |
| コード長 | 673 bytes |
| コンパイル時間 | 72 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-09-17 16:26:18 |
| 合計ジャッジ時間 | 1,427 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
def Decimal(Binary):
ans = 0
for i in range(len(Binary)):
ans += int(Binary.pop()) * 2**i
print(ans)
def Cal(length, B_1, B_2):
Binary = [0 for i in range(length)]
for i in range(len(B_1) - 1, -1, -1):
if B_2:
P_1, P_2 = int(B_1.pop()), int(B_2.pop())
if P_1 + P_2 == 2:
Binary[i] = "0"
else:
Binary[i] = str(P_1 + P_2)
else:
P_1 = int(B_1.pop())
Binary[i] = str(P_1)
return Binary
B_1 = list(str(input()))
B_2 = list(str(input()))
if len(B_2) > len(B_1):
B_1, B_2 = B_2, B_1
Binary = Cal(len(B_1), B_1, B_2)
Decimal(Binary)