結果
| 問題 |
No.2397 ω冪
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-15 21:07:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,479 bytes |
| コンパイル時間 | 226 ms |
| コンパイル使用メモリ | 82,352 KB |
| 実行使用メモリ | 59,184 KB |
| 最終ジャッジ日時 | 2025-04-15 21:13:43 |
| 合計ジャッジ時間 | 2,783 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 WA * 11 |
ソースコード
def decompose(s):
if s == '0':
return ('0', 0)
i = len(s) - 1
while i >= 0 and s[i] == '0':
i -= 1
b = len(s) - 1 - i
s_trimmed = s[:i+1]
if len(s_trimmed) == 1 and s_trimmed[0] == '1':
s_minus_1 = '0'
else:
s_minus_1 = s_trimmed[:-1] + '0'
if s_minus_1 == '0':
a_str = '0'
else:
a_str = s_minus_1[:-1] if len(s_minus_1) > 1 else '0'
return (a_str, b)
def is_less_iter(n_str, m_str):
stack = []
stack.append((n_str, m_str, False))
result = None
while stack and result is None:
current_n, current_m, compare_a = stack.pop()
if compare_a:
stack.append((current_n, current_m, False))
else:
if current_n == '0':
if current_m == '0':
continue
else:
result = True
break
if current_m == '0':
result = False
break
a_n, b_n = decompose(current_n)
a_m, b_m = decompose(current_m)
b_n_str = bin(b_n)[2:] if b_n != 0 else '0'
b_m_str = bin(b_m)[2:] if b_m != 0 else '0'
stack.append((a_n, a_m, True))
stack.append((b_n_str, b_m_str, False))
return result if result is not None else False
n = input().strip()
m = input().strip()
if n == '0' and m == '0':
print("No")
else:
print("Yes" if is_less_iter(n, m) else "No")
lam6er