Cod sursa(job #726313)
| Utilizator | Data | 27 martie 2012 10:06:19 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <cstdio>
using namespace std;
int a,b;
long long pow(int a, int b)
{
long long aux=1;
if (b==1) return a;
else
{
if (b%2==0)
{
aux=pow(a,b/2)%1999999973;
return aux*aux%1999999973;
}
else return a*pow(a,b-1)%1999999973;
}
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%d%d",&a,&b);
printf("%lld",pow(a,b)%1999999973);
return 0;
}
