Cod sursa(job #1554437)
| Utilizator | Data | 21 decembrie 2015 12:41:26 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <cstdio>
#include <cmath>
#define MOD 1999999973
using namespace std;
int lgput(long long x, int y)
{
int z=1;
while(y!=0)
{
if(y%2==0)
{
x=(x*x)%MOD;
y/=2;
}
else
{
z=(z*x)%MOD;
y-=1;
}
}
return z;
}
int main()
{
int a,b,c;
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%d %d", &a, &b);
c=lgput(a,b);
printf("%d", c);
return 0;
}
