UOJ 66. 新年的巧克力棒

目测发现ans=x-bitcount(x)

#include<bits/stdc++.h>
using namespace std;
int T,n,x;
signed main () {
    scanf("%d",&T);
    while (T--) {
        scanf("%d",&n);x=n;
        while (x) {
            n--;
            x-=x&-x;
        }
        printf("%d
",n);
    } return 0;
}
原文地址:https://www.cnblogs.com/rrsb/p/9867212.html