Cod sursa(job #1936442)
Utilizator | Data | 23 martie 2017 08:57:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 80 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <cstdio>
using namespace std;
const long long MOD = 1999999973;
long long n, m;
void citire()
{
scanf("%lld %lld", &n, &m);
}
long long putere(long long x, long long y)
{
if(y == 1)
{
return x % MOD;
}
else
{
if(y % 2 == 0)
{
return putere((x * x % MOD), y / 2) % MOD;
}
else
{
return x * (putere(x * x % MOD, y / 2) % MOD);
}
}
}
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
citire();
printf("%lld", putere(n, m));
}