Cod sursa(job #660333)
| Utilizator | Data | 12 ianuarie 2012 12:30:39 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <cstdio>
#define M 1999999973
using namespace std;
long long n,k;
long long pow (int n, int k)
{
if (k==0) return 1;
if (k%2==0)
{
long long aux=pow(n,k/2);
return (aux*aux)%M;
}
else
return (n*pow(n,k-1))%M;
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%lld%lld",&n,&k);
printf("%lld\n",pow(n,k));
}
