Cod sursa(job #1749692)
Utilizator | Data | 28 august 2016 15:56:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using ll = long long;
ll
go(ll n,
ll p)
{
ll temp;
if (1 == p)
{
return n;
}
temp = go(n, p / 2);
if (p & 1)
{
return (temp * temp * n) % 1999999973;
}
return (temp * temp) % 1999999973;
}
int main()
{
ll n;
ll p;
std::cin >> n >> p;
std::cout << go(n, p);
return 0;
}