結果
問題 | No.2397 ω冪 |
ユーザー |
![]() |
提出日時 | 2025-06-12 14:24:28 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,676 bytes |
コンパイル時間 | 139 ms |
コンパイル使用メモリ | 82,540 KB |
実行使用メモリ | 74,488 KB |
最終ジャッジ日時 | 2025-06-12 14:24:40 |
合計ジャッジ時間 | 2,751 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 11 |
ソースコード
import sys sys.setrecursionlimit(1 << 25) def count_trailing_zeros(s): count = 0 for c in reversed(s): if c == '0': count += 1 else: break return count def subtract_one(s): s_list = list(s) i = len(s_list) - 1 while i >= 0 and s_list[i] == '0': s_list[i] = '1' i -= 1 if i >= 0: s_list[i] = '0' new_s = ''.join(s_list).lstrip('0') return new_s if new_s else '0' def divide_by_two(s): if s == '0': return '0' return s[:-1] if len(s) > 1 else '0' def compare(n_bin, m_bin): n = n_bin.lstrip('0') or '0' m = m_bin.lstrip('0') or '0' if n == '0' and m == '0': return 0 if n == '0': return -1 if m == '0': return 1 # Decompose n b_n = count_trailing_zeros(n) rest_n = n[:-b_n] if b_n > 0 else n if not rest_n: a_n = '0' else: rest_minus1 = subtract_one(rest_n) a_n = divide_by_two(rest_minus1) # Decompose m b_m = count_trailing_zeros(m) rest_m = m[:-b_m] if b_m > 0 else m if not rest_m: a_m = '0' else: rest_minus1_m = subtract_one(rest_m) a_m = divide_by_two(rest_minus1_m) # Compare b_n and b_m if b_n == 0: b_n_bin = '0' else: b_n_bin = bin(b_n)[2:] if b_m == 0: b_m_bin = '0' else: b_m_bin = bin(b_m)[2:] cmp_b = compare(b_n_bin, b_m_bin) if cmp_b != 0: return cmp_b # Compare a_n and a_m return compare(a_n, a_m) n = input().strip() m = input().strip() result = compare(n, m) print("Yes" if result == -1 else "No")