Cod sursa(job #636156)
| Utilizator | Data | 19 noiembrie 2011 17:28:29 | |
|---|---|---|---|
| Problema | Ciuperci | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | .com 2011 | Marime | 0.47 kb |
#include <cstdio>
#define mod 666013
#define ll long long
int q, c;
ll n;
ll solve (ll n)
{
if (n==1) return 0;
if (n==2) return 1;
n--;
ll x, y=n/2;
if (n&1)
{
x=solve(y);
y=solve(y+1);
return 1+x+y;
} else
{
x=solve(y);
return 2*x;
}
}
int main()
{
freopen("ciuperci.in","r",stdin);
freopen("ciuperci.out","w",stdout);
scanf("%d", &q);
ll c;
while (q--)
{
scanf("%lld", &n);
c=solve(n);
printf("%lld\n",c);
//printf("%lld\n", pow(2,c));
}
}