我勒个暴力

· · 题解

首先很容易打出以下暴力代码,由于求最大从 2^n-1 开始枚举并检验。

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int n;
    cin >> n;
    for(int i = (1ll << n) - 1; i >= 1; i--)
    {
        if(__builtin_ctz(i & -i) == __builtin_popcountll(i))
        {
            cout << i;
            return 0;
        }
    }
}

然后跑所有可能的输入 n,会发现都能在 1\text s 内跑过,所以上面的代码就是答案。