結果

問題 No.3276 Make Smaller Popcount
コンテスト
ユーザー わん
提出日時 2025-10-23 16:17:35
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 235 ms / 2,000 ms
+ 951µs
コード長 336 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 226 ms
コンパイル使用メモリ 95,724 KB
実行使用メモリ 86,272 KB
最終ジャッジ日時 2026-07-15 20:27:56
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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