結果

問題 No.3276 Make Smaller Popcount
ユーザー 👑 SPD_9X2
提出日時 2025-09-19 22:43:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 759 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 77,584 KB
最終ジャッジ日時 2025-09-19 22:43:57
合計ジャッジ時間 18,829 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

p2 = set([2**i for i in range(100)])

TT = int(input())

for loop in range(TT):

    N = int(input())
    if N in p2:
        print (-1)
        continue
    
    M = N
    pc = N.bit_count()

    for i in range(30):
        if (2**i) & M:
            M += 2**i
            if M.bit_count() < pc:
                print (M-N)
                break

                
0