結果
問題 |
No.2397 ω冪
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:09:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,665 bytes |
コンパイル時間 | 325 ms |
コンパイル使用メモリ | 82,284 KB |
実行使用メモリ | 74,944 KB |
最終ジャッジ日時 | 2025-06-12 14:09:56 |
合計ジャッジ時間 | 2,973 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 11 |
ソースコード
def count_trailing_zeros(s): count = 0 i = len(s) - 1 while i >= 0 and s[i] == '0': count += 1 i -= 1 return count def subtract_one(s): s_list = list(s) i = len(s_list) - 1 while i >= 0 and s_list[i] == '0': i -= 1 if i < 0: return '0' s_list[i] = '0' j = i + 1 while j < len(s_list): s_list[j] = '1' j += 1 new_s = ''.join(s_list).lstrip('0') if not new_s: return '0' return new_s def right_shift(s, amount=1): if amount >= len(s): return '0' return s[:-amount] def decompose(n_str): if n_str == '0': return ('0', '0') b = count_trailing_zeros(n_str) if b == len(n_str): return ('0', '0') s_prime = n_str[:-b] if b > 0 else n_str s_double_prime = subtract_one(s_prime) if s_double_prime is None: s_double_prime = '0' s_triple_prime = right_shift(s_double_prime, 1) if not s_triple_prime: s_triple_prime = '0' a_str = s_triple_prime n1_str = bin(b)[2:] if b != 0 else '0' return (a_str, n1_str) def compare(n_str, m_str): if n_str == '0' and m_str == '0': return 0 if n_str == '0': return -1 if m_str == '0': return 1 a_str, n1_str = decompose(n_str) b_str, m1_str = decompose(m_str) cmp1 = compare(n1_str, m1_str) if cmp1 < 0: return -1 elif cmp1 > 0: return 1 else: cmp0 = compare(a_str, b_str) return cmp0 # Read input N = input().strip() M = input().strip() # Determine the result result = compare(N, M) if result == -1: print("Yes") else: print("No")