結果

問題 No.3276 Make Smaller Popcount
コンテスト
ユーザー わん
提出日時 2025-10-23 16:17:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,220 KB
実行使用メモリ 78,840 KB
最終ジャッジ日時 2025-10-23 16:17:47
合計ジャッジ時間 11,592 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input=sys.stdin.readline

def solve(x):
  y = x
  xcnt = x.bit_count()
  if xcnt == 1:
    return -1
  for i in range(1, 40):
    y = x
    y >>= i
    y <<= i
    y |= 1<<i
    if y>x and y.bit_count()<xcnt:
      return y-x

if __name__ == '__main__':
  T = int(input())
  for i in range(T):
    print(solve(int(input())))
0