您的位置:首页 > 其它

HDU 2568.前进

2018-01-09 23:16 253 查看
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2568

AC代码(C++):

#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <algorithm>
#include <string.h>
#include <math.h>

#define INF 0x3f3f3f3f
#define eps 1e-8
typedef unsigned long long ULL;

using namespace std;

int n;

int main() {
int t;
cin >> t;
while (t--) {
cin >> n;
int cnt = 0;
while (n != 0) {
if (n % 2 == 0)n /= 2;
else {
n--;
cnt++;
}
}
cout << cnt << endl;
}

//system("pause");
}

总结: 水题.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: