Cod sursa(job #3003376)
Utilizator | Data | 15 martie 2023 18:09:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n, p, x=1;
fin >> n >> p;
while (p!=0) {
if (p%2==0) {
n=n*n%mod;
}
else {
x=x*n%mod;
}
p=p/2;
}
fout << x;
return 0;
}