Cod sursa(job #504847)
| Utilizator | Data | 28 noiembrie 2010 23:33:15 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <cstdio>
#define nmax 4700000
#define MOD 1999999973
using namespace std;
FILE *fin=fopen("lgput.in", "r");
FILE *fout=fopen("lgput.out", "w");
long long rez;
long long n, m, a;
int main()
{
fscanf(fin, "%lld%lld", &n, &m);
a=n; rez=1;
for(int i=0; (1<<i) <= m; ++i)
{
if((1<<i) & m)
rez = (rez * a) % MOD;
a = (a*a) % MOD;
}
fprintf(fout, "%lld", rez);
return 0;
}
