Cod sursa(job #635654)

Utilizator cosmin79Carabet Cosmin Andrei cosmin79 Data 19 noiembrie 2011 13:53:30
Problema Ciuperci Scor 30
Compilator cpp Status done
Runda .com 2011 Marime 0.57 kb
#include <stdio.h>
#include <map>
#define ll long long
#define MOD 666013
using namespace std;
int t;
ll n;
map <ll,int> H;
inline int calcul(ll n)
{
	if (n==0)
		return 1;
	if (n==1)
		return 1;
	int act=H[n];
	if (act)
		return act;
	if (n % 2==1)
		act=((ll)calcul(n/2)*calcul(n/2))%MOD;
	else
		act=((ll)calcul(n/2)*calcul(n/2-1)*2)%MOD;
	H[n]=act;
	return act;
}
int main()
{
	freopen("ciuperci.in","r",stdin);
	freopen("ciuperci.out","w",stdout);
	scanf("%d",&t);
	while (t--)
	{
		scanf("%lld",&n);
		printf("%d\n",calcul(n));
	}
	return 0;
}