Cod sursa(job #2805881)
Utilizator | Data | 22 noiembrie 2021 04:19:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n, p, s;
int main()
{
fin >> n >> p;
s = 1;
while(p != 0)
{
if(p%2 == 1)
s = (s * n) % 1999999973;
n = (n*n) % 1999999973;
p /= 2;
}
fout << s;
return 0;
}