結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
![]() |
提出日時 | 2025-09-19 21:26:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 903 ms / 2,000 ms |
コード長 | 395 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 82,656 KB |
実行使用メモリ | 77,044 KB |
最終ジャッジ日時 | 2025-09-19 21:27:14 |
合計ジャッジ時間 | 26,528 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
query = int(input()) for i in range(query): n = int(input()) s = [int(_) for _ in str(bin(n)[2:])] # print(s) s.reverse() now = 1 ans = 0 count = 0 for j in s: if j == 1: if count == 0: ans += now count += 1 else: count += 1 else: if count == 1: ans += now now *= 2 if count == 1: print(-1) else: print(ans)