結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
|
提出日時 | 2025-09-20 02:03:11 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 561 ms / 2,000 ms |
コード長 | 367 bytes |
コンパイル時間 | 388 ms |
コンパイル使用メモリ | 82,356 KB |
実行使用メモリ | 77,264 KB |
最終ジャッジ日時 | 2025-09-20 02:03:30 |
合計ジャッジ時間 | 18,184 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
q = int(input()) while q: q -= 1 n = int(input()) pc = 0 m = n while m: pc += m & 1 m >>= 1 if pc == 1: print(-1) continue flag = 0 ans = 0 for id in range(30): if flag: if (n & (1 << id)): break else: ans += 1 << id else: if (n & (1 << id)): ans += 1 << id flag = 1 else: pass print(ans)