码迷,mamicode.com
首页 > 其他好文 > 详细

HDU2568 前进

时间:2018-10-04 10:57:10      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:include   namespace   mat   amp   space   names   ret   style   class   

#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(void)
{
    int t;
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            int n;
            scanf("%d",&n);
            int cnt = 0;
            while(n)
            {
                if(n%2==0)
                {
                    n = n / 2;
                }
                else
                {
                    cnt++;
                    n = n - 1;
                }
            }
            printf("%d\n",cnt);
        }
        
    }
    return 0;
} 

 

HDU2568 前进

标签:include   namespace   mat   amp   space   names   ret   style   class   

原文地址:https://www.cnblogs.com/AC-AC/p/9739615.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!