結果
| 問題 |
No.3276 Make Smaller Popcount
|
| コンテスト | |
| ユーザー |
a01sa01to
|
| 提出日時 | 2025-09-22 01:02:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 631 bytes |
| コンパイル時間 | 3,040 ms |
| コンパイル使用メモリ | 275,444 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-09-22 01:02:11 |
| 合計ジャッジ時間 | 7,247 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
if (popcount(ull(n)) == 1) {
cout << -1 << '\n';
}
else {
int x = 0;
for (int i = 0; i < 30; ++i) {
if (n & (1 << i)) {
if (x == 0) {
x = -(1 << i);
}
else {
x += (1 << i);
break;
}
}
}
cout << x << '\n';
}
}
return 0;
}
a01sa01to