結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
|
提出日時 | 2025-09-19 21:37:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 410 ms / 2,000 ms |
コード長 | 492 bytes |
コンパイル時間 | 1,026 ms |
コンパイル使用メモリ | 87,184 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-19 21:38:17 |
合計ジャッジ時間 | 14,324 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include <iostream> #include <vector> #include <queue> using namespace std; using ll = long long; void solve() { ll N;cin >> N; if (__builtin_popcount(N) == 1) { cout << -1 << endl; return; } int K = 35; ll res = 0; for (int i = 0;i < K;i++) { if (N & (1LL << i)) { res |= (1LL << i); for (int k = i+1;k < K;k++) { if (N & (1LL << k)) break; res |= (1LL << k); } cout << res << endl; return; } } } int main() { int t;cin >> t; while (t--) solve(); }