Cod sursa(job #2979163)
Utilizator | Data | 14 februarie 2023 20:05:55 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | 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 n, p;
fin >> n >> p;
long long np = 1;
long long a = n;
do{
if(p % 2 == 1){
np = (np * a)%1999999973;
}
p = p / 2;
a = (a * a)%1999999973;
}while(p != 0);
fout << np;
return 0;
}