結果
問題 |
No.3276 Make Smaller Popcount
|
ユーザー |
|
提出日時 | 2025-09-19 21:38:21 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 780 bytes |
コンパイル時間 | 1,923 ms |
コンパイル使用メモリ | 194,844 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-19 21:39:08 |
合計ジャッジ時間 | 15,395 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 5 WA * 23 |
ソースコード
#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 << i; printf("%lld\n", t - n); break; } } } } return 0; }