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",n); } return 0; }
目测发现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",n); } return 0; }