Pagini recente » Cod sursa (job #220739) | Cod sursa (job #1338892) | Cod sursa (job #2143357) | Cod sursa (job #2942049) | Cod sursa (job #1522453)
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 666013
using namespace std;
int n, q;
void read()
{
freopen("ciuperci.in", "r", stdin);
scanf("%d", &q);
}
void solve(int n, long long &x, long long &y)
{
if (n == 0)
{
x = 1;
y = 1;
return ;
}
if (n == 1)
{
x = 2;
y = 1;
return ;
}
long long a, b;
if (n & 1)
{
solve(n >> 1, a, b);
y = (b * b * 1LL) % mod;
x = (2 * a * b * 1LL) % mod;
}else
{
solve((n >> 1) - 1, a, b);
x = (a * a * 1LL) % mod;
y = (2 * a * b * 1LL) % mod;
}
}
void write()
{
long long a, b, x;
freopen("ciuperci.out", "w", stdout);
while (q --)
{
scanf("%lld", &x);
solve(x, a, b);
printf("%lld\n", b);
}
}
int main()
{
read();
write();
return 0;
}