Cod sursa(job #2823744)
Utilizator | Data | 29 decembrie 2021 15:57:27 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n, p, rez = 1;
fin >> n >> p;
for (p; p != 1; p/=2)
{
if (p % 2 == 1)
rez *= n;
n *= n;
}
n *= rez;
fout << n % 1999999973;
}