Dylans loves numbersaccepts:405submissions:831Time limit:2000/1000 MS (java/others)Memory limit:131072/131072 K (java/others) Problem description
Who is Dylans? You can see him on Uoj and Codeforces. In Bestcoder, he had another id:s1451900. Today's topic is related to him oh. Dylans got a number
N
。 He wants to know that there are several sets of 1 in the binary of N. If there are several (at least one) 0 "block" between two 1, they are not in the same group, otherwise they are the same group.Enter a description
The first line reads in a number
T
Represents the number of data groups. Next
T
Line, one number per line
N
。
0 ≤ ≤ 10 18 , t ≤
Output description
For each set of data, output a number to indicate the answer.
Input sample
15
Output sample
2
#include <cstdio> #include <algorithm>unsigned long long n,n,res,flag;int main () { scanf ("%lld", &n ); while (n--) { scanf ("%lld", &n); res=0,flag=0; while (N) {// printf ("%lld", n%2); if (n%2==1 && flag==0) {flag=1; res++;} else if (n%2==0) flag=0; n/=2; } printf ("%lld\n", res); } return 0;}Now, do this water problem.
Dylans loves numbers