結果
| 問題 | No.3276 Make Smaller Popcount |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-19 21:45:15 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 207 ms / 2,000 ms |
| + 469µs | |
| コード長 | 786 bytes |
| 記録 | |
| コンパイル時間 | 1,114 ms |
| コンパイル使用メモリ | 208,512 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-15 03:37:58 |
| 合計ジャッジ時間 | 9,185 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pli;
const int N = 2000086, MOD = 1e9 + 7, INF = 0x3f3f3f3f;
ll res;
int n, m, cnt, w[N];
int a[20][20];
int main() {
int T;
cin >> T;
while (T--) {
cin >> n;
int c = 0;
if (__builtin_popcount(n) == 1) {
puts("-1");
continue;
}
for (int j = 0; j <= 30; j++) {
if (n >> j & 1) c++;
else {
if (c > 1) {
ll t = 1 << j;
for (int i = j + 1; i <= 30; i++) t += (n >> i & 1) << i;
printf("%lld\n", t - n);
break;
}
}
}
}
return 0;
}