1 条题解

  • 1
    @ 2023-9-22 15:16:50

    显然答案是n的最近二次幂减一,也就是所谓的high_bit-1

    #include <bits/stdc++.h>
    #define int unsigned long long
    using namespace std;
    
    int high_bit(int x)
    {
        return 1ull << (31 - __builtin_clz(x));
    }
    signed main()
    {
        int n;
        cin >> n;
        cout << high_bit(n)-1;
        return 0;
    }
    
    • 1

    信息

    ID
    449
    时间
    1000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    66
    已通过
    0
    上传者