Cod sursa(job #635718)
| Utilizator | Data | 19 noiembrie 2011 14:27:24 | |
|---|---|---|---|
| Problema | Ciuperci | Scor | 30 |
| Compilator | cpp | Status | done |
| Runda | .com 2011 | Marime | 0.53 kb |
# include <cstdio>
typedef long long ll;
const char *FIN = "ciuperci.in", *FOU = "ciuperci.out";
const int MOD = 666013;
int T;
ll N;
inline int rez (ll N) {
if (N == 0 || N == 1) return 1;
ll aux = rez (N >> 1);
if (N & 1)
return (aux * aux) % MOD;
return (aux * rez ((N >> 1) - 1) << 1) % MOD;
}
int main (void) {
freopen (FIN, "r", stdin);
freopen (FOU, "w", stdout);
for (scanf ("%d", &T); T; --T) {
scanf ("%lld", &N);
printf ("%d\n", rez (N));
}
}
