mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
da5da8ec9f
3100-3199
28 lines
492 B
C++
28 lines
492 B
C++
#include <stdio.h>
|
|
#include <string.h>
|
|
int a[10002];
|
|
int dg(long n)
|
|
{
|
|
if(n==1||n==2||n==0)
|
|
return 0;
|
|
if(n%2==0)
|
|
return dg(n/2)*2;
|
|
else
|
|
return dg(n/2)+dg(n-n/2)+1;
|
|
}
|
|
int main(int argc, char* argv[])
|
|
{
|
|
int n;
|
|
int i;
|
|
long num;
|
|
scanf("%d", &n);
|
|
memset(a,-1, sizeof(a));
|
|
a[0]=a[1]=a[2]= 0;
|
|
for (i = 0; i < n; i++)
|
|
{
|
|
scanf("%ld", &num);
|
|
printf("%ld\n", dg(num));
|
|
}
|
|
return 0;
|
|
}
|