Cod sursa(job #1227631)

Utilizator touristGennady Korotkevich tourist Data 10 septembrie 2014 23:03:10
Problema Ciuperci Scor 30
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.58 kb
#include <cstdio>
#include <vector>
#define mod 666013

using namespace std;

inline int Solve(long long x)
{
    int aux;
    if(x<=1) return 1;
    --x;
    if(x%2==0)
    {
        aux=(1LL*Solve(x/2)*Solve(x/2))%mod;
        return aux;
    }
    aux=(2LL*Solve(x/2)*Solve(x/2+1))%mod;
    return aux;
}

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