Cod sursa(job #2190429)
Utilizator | Data | 30 martie 2018 19:13:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long a, b, m = 1999999973, sol = 1;
fin >> a >> b;
for (; b; b >>= 1)
{
if (b & 1)
{
sol = sol * a % m;
}
a = a * a % m;
}
fout << sol << '\n';
return 0;
}