Cod sursa(job #547488)
| Utilizator | Data | 6 martie 2011 13:21:54 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.46 kb |
#include <cstdio>
#include <cassert>
#define Mod 1999999973
#define InFile "lgput.in"
#define OutFile "lgput.out"
using namespace std;
long long n, p, a, sol=1;
int main()
{
int i;
assert (freopen (InFile, "r", stdin));
assert (freopen (OutFile, "w", stdout));
scanf ("%lld %lld\n", &n, &p);
a=n;
for (i=0; (1<<i)<=p; i++)
{
if (p & (1<<i))
sol=(sol*a)%Mod;
a=(a*a)%Mod;
}
printf ("%lld\n", sol);
return 0;
}
