Cod sursa(job #1610325)
| Utilizator | Data | 23 februarie 2016 14:03:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <cstdio>
#include <algorithm>
using namespace std;
int const MOD=1999999973;
long long pow(long long x, long long k)
{
long long a=1;
while(k)
{
if(k%2==1)
a=(a*x)%MOD, k--;
x=(x*x)%MOD;
k=k/2;
}
return a;
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out","w", stdout);
long long n,p;
scanf("%lld%lld", &n, &p);
printf("%lld", pow(n,p));
return 0;
}
