Cod sursa(job #1635363)
| Utilizator | Data | 6 martie 2016 17:05:23 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <cstdio>
using namespace std;
#define Max 1999999973
unsigned long long int n,p;
unsigned long long int pwr(unsigned long long int x,unsigned long long int y)
{
if(y==1)
return x;
else if(y%2==0)
return pwr(x*x,y/2);
else return x*pwr(x*x,y/2);
}
int main()
{
freopen("lgput.in","r",stdin);
freopen("lgput.out","w",stdout);
scanf("%llu%llu",&n,&p);
printf("%llu",pwr(n,p)%Max);
return 0;
}
