Cod sursa(job #2705667)
Utilizator | Data | 13 februarie 2021 09:51:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p, r;
int main()
{
fin >> n >> p;
r = 1;
n = n % 1999999973;
while (p)
{
if (p % 2 == 1) r = (r * n) % 1999999973;
p /= 2;
n = (n * n) % 1999999973;
}
fout << r % 1999999973;
return 0;
}