結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
|
提出日時 | 2025-09-20 01:02:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 68 ms / 2,000 ms |
コード長 | 442 bytes |
コンパイル時間 | 1,703 ms |
コンパイル使用メモリ | 194,488 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-20 01:02:50 |
合計ジャッジ時間 | 5,974 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int T; cin >> T; while(T--){ int N; cin >> N; if(__popcount(N) == 1){cout << "-1\n"; continue;} int n = N,answer = N; while(true){ answer += answer&-answer; if(__popcount(answer) < __popcount(N)) break; } cout << answer-N << "\n"; } }