Cod sursa(job #1661826)
Utilizator | Data | 24 martie 2016 11:00:42 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
std::ifstream in("lgput.in");
std::ofstream out("lgput.out");
using t = unsigned long long;
t pow(t x , t n)
{
if(n==0) return 1;
if(n==1) return x;
if(n%2==0) return pow(x*x,n/2);
return pow(x*x,(n-1)/2);
}
main()
{
t a, b;
in >> a >> b;
out << pow(a,b) % 1999999973;
}