Dylans loves numbers

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.