結果
| 問題 | No.683 Two Operations No.3 |
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 21:34:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,168 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,344 KB |
| 実行使用メモリ | 67,052 KB |
| 最終ジャッジ日時 | 2025-06-12 21:36:31 |
| 合計ジャッジ時間 | 4,122 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 2 TLE * 1 -- * 9 |
ソースコード
def can_reach_zero(A, B):
while True:
if A == 0 and B == 0:
return True
# Check if both are odd and greater than zero
if (A % 2 == 1) and (B % 2 == 1) and (A != 0 or B != 0):
return False
# Check possible operations
op1_possible = False
new_a1 = 0
new_b1 = 0
if A % 2 == 0 and B >= 1:
op1_possible = True
new_a1 = A // 2
new_b1 = B - 1
op2_possible = False
new_a2 = 0
new_b2 = 0
if B % 2 == 0 and A >= 1:
op2_possible = True
new_a2 = A - 1
new_b2 = B // 2
if not op1_possible and not op2_possible:
return False
if op1_possible and op2_possible:
sum1 = new_a1 + new_b1
sum2 = new_a2 + new_b2
if sum1 <= sum2:
A, B = new_a1, new_b1
else:
A, B = new_a2, new_b2
elif op1_possible:
A, B = new_a1, new_b1
else:
A, B = new_a2, new_b2
A, B = map(int, input().split())
if can_reach_zero(A, B):
print("Yes")
else:
print("No")
gew1fw