Cod sursa(job #1094744)
Utilizator | Data | 29 ianuarie 2014 19:50:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
#define CONSTANT 1999999973
using namespace std;
FILE* f=freopen("lgput.in","r",stdin);
FILE* o=freopen("lgput.out","w",stdout);
long n,m;
long Power(int a, int x)
{
if(x==0) return 1;
if(x%2)
{
return ((Power(a,x/2)%CONSTANT*Power(a,x/2)*a)%CONSTANT)%CONSTANT;
}
else
{
return (Power(a,x/2)%CONSTANT*Power(a,x/2)%CONSTANT)%CONSTANT;
}
}
int main()
{
scanf("%ld%ld",&n,&m);
printf("%ld",Power(n,m));
return 0;
}