結果
| 問題 | No.3276 Make Smaller Popcount | 
| コンテスト | |
| ユーザー |  Jikky1618 | 
| 提出日時 | 2025-09-20 01:28:51 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 934 bytes | 
| コンパイル時間 | 2,816 ms | 
| コンパイル使用メモリ | 276,152 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-09-20 01:28:58 | 
| 合計ジャッジ時間 | 6,596 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 22 WA * 6 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...)
#endif
void solve() {
    int N;
    cin >> N;
    // popcount(N) = 1 の場合, No
    if (__builtin_popcount(N) == 1) {
        cout << "No" << "\n";
        return;
    }
    // 右から 2 個目の 1 の位置を求める
    int ctz = __builtin_ctz(N), ctz2 = 30;
    for (int i = ctz + 1; i < 30; i++) {
        if (N & (1 << i)) {
            ctz2 = i;
            break;
        }
    }
    int N2 = N - (1 << ctz) - (1 << ctz2);
    for (int i = ctz2 + 1; i < 30; i++) {
        int M = N2 + (1 << i);
        if (__builtin_popcount(M) < __builtin_popcount(N)) {
            cout << M - N << "\n";
            return;
        }
    }
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int T;
    cin >> T;
    while (T--) solve();
}
            
            
            
        