結果
| 問題 | No.3276 Make Smaller Popcount | 
| コンテスト | |
| ユーザー | 👑 | 
| 提出日時 | 2025-09-19 22:22:04 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 692 ms / 2,000 ms | 
| コード長 | 397 bytes | 
| コンパイル時間 | 175 ms | 
| コンパイル使用メモリ | 82,680 KB | 
| 実行使用メモリ | 76,908 KB | 
| 最終ジャッジ日時 | 2025-09-19 22:22:59 | 
| 合計ジャッジ時間 | 19,790 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 28 | 
ソースコード
def solve():
    N = int(input())
    if N.bit_count() == 1:
        print(-1)
        return
    for i in range(31):
        v = (N | (1 << i)) & ~((1 << i) - 1)
        if v <= N:
            continue
        if v.bit_count() >= N.bit_count():
            continue
        print(v - N)
        return
if __name__ == "__main__":
    T = int(input())
    for _ in range(T):
        solve()
            
            
            
        