結果
問題 |
No.638 Sum of "not power of 2"
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:31:27 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 36 ms / 1,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,788 KB |
実行使用メモリ | 54,208 KB |
最終ジャッジ日時 | 2025-03-20 20:32:32 |
合計ジャッジ時間 | 1,242 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 12 |
ソースコード
n = int(input()) def is_power_of_two(x): return (x & (x - 1)) == 0 and x != 0 invalid = {1, 2, 3, 4, 5, 7} if n in invalid: print(-1) else: candidates = [] current = 3 max_candidates = 200 while len(candidates) < max_candidates and current <= 2 * 10**5: if not is_power_of_two(current): candidates.append(current) current += 1 found = False for a in candidates: if a >= n: continue b = n - a if b <= 0: continue if not is_power_of_two(b): print(a, b) found = True break if not found: print(-1)