Cod sursa(job #636471)
Utilizator | Data | 19 noiembrie 2011 20:38:16 | |
---|---|---|---|
Problema | Ciuperci | Scor | 0 |
Compilator | cpp | Status | done |
Runda | .com 2011 | Marime | 0.45 kb |
# include <fstream>
using namespace std;
ifstream f ("ciuperci.in");
ofstream g ("ciuperci.out");
long long int n,x,i;
long long int calc(long long int x)
{
if (x==1)
return 1;
if (x==2)
return 2;
if (x%2==1)
{
long long int y=calc((x-1)/2);
return y*y;
}
else
return 2*calc((x-1)/2)*calc (x/2);
}
int main ()
{
f>>n;
for (i=1;i<=n;i++)
{
f>>x;
g<<calc (x)<<"\n";
}
return 0;
}