Cod sursa(job #636193)

Utilizator MinionMinionul nr. 4 Minion Data 19 noiembrie 2011 17:40:26
Problema Ciuperci Scor 30
Compilator cpp Status done
Runda .com 2011 Marime 0.55 kb
#include <cstdio>

typedef long long i64;

inline i64 fct(i64 x)
{
    if (x<2)
        return 1;
    if (x&(x-1)==0)
        return 1;
    else if (x&1)
    {
        i64 aux=fct(x>>1);
        return (aux*aux)%666013;
    }
    else
        return (2*fct(x>>1)*fct((x>>1)-1))%666013;

}

int main()
{
    int t;
    long long n;
    freopen("ciuperci.in","r",stdin);
    freopen("ciuperci.out","w",stdout);
    scanf("%d",&t);
    for (;t;--t)
    {
        scanf("%lld",&n);
        printf("%lld\n",fct(n));
    }
    return 0;
}