1.题目描述:
B. Kids' Riddle
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output
Programmers' kids solve this riddle in 5-10 minutes. How fast can you do it?
Input
The input contains a single integer n (0 ≤ n ≤ 2000000000).
Output
Output a single integer.
Examples
input
11
output
2
input
14
output
0
input
61441
output
2
input
571576
output
10
input
2128506
output
3
愚人节快乐
3.解题思路:
二进制???WA
圈的个数??WA
十六进制的圈个数??Accepted
4.AC代码:
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define maxn 100100
#define N 1111
#define eps 1e-6
#define pi acos(-1.0)
#define e exp(1.0)
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
int a[16] = { 1,0,0,0,1,0,1,0,2,1,1,2,0,1,0,0 };
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
long _begin_time = clock();
#endif
int n;
while(~scanf("%d", &n))
{
int cnt = a[n % 16];
n /= 16;
while (n)
{
cnt += a[n % 16];
n /= 16;
}
printf("%d\n", cnt);
}
#ifndef ONLINE_JUDGE
long _end_time = clock();
printf("time = %ld ms.", _end_time - _begin_time);
#endif
return 0;
}