結果
問題 |
No.2397 ω冪
|
ユーザー |
![]() |
提出日時 | 2025-06-12 14:21:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,334 bytes |
コンパイル時間 | 224 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 420,608 KB |
最終ジャッジ日時 | 2025-06-12 14:21:51 |
合計ジャッジ時間 | 3,589 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 26 WA * 14 RE * 1 |
ソースコード
def count_trailing_zeros(s): count = 0 for c in reversed(s): if c == '0': count += 1 else: break return count def get_a_part(s, b): if b == 0: new_s = s else: new_s = s[:-b] if len(s) > b else '' if not new_s: return '0' if new_s == '1': a_minus1_str = '0' else: a_minus1_str = new_s[:-1] + '0' a_str = a_minus1_str.rstrip('0') or '0' return a_str def decimal_to_bin(num): if num == 0: return '0' res = [] while num > 0: res.append(str(num % 2)) num = num // 2 return ''.join(reversed(res)) or '0' def compare(n1_str, n2_str): if n1_str == '0' and n2_str == '0': return 0 if n1_str == '0': return -1 if n2_str == '0': return 1 b1 = count_trailing_zeros(n1_str) a1_str = get_a_part(n1_str, b1) b2 = count_trailing_zeros(n2_str) a2_str = get_a_part(n2_str, b2) b1_str = decimal_to_bin(b1) b2_str = decimal_to_bin(b2) cmp_b = compare(b1_str, b2_str) if cmp_b != 0: return cmp_b return compare(a1_str, a2_str) n_str = input().strip() m_str = input().strip() if not n_str: n_str = '0' if not m_str: m_str = '0' result = compare(n_str, m_str) print("Yes" if result == -1 else "No")