Cod sursa(job #3182546)
Utilizator | Data | 9 decembrie 2023 09:52:49 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n, P, res = 1;
fin >> n >> P;
const int mod=1999999973;
while (P>0)
{
if (P % 2 == 1)
res = (res * n) % mod ;
n = (n*n) % mod ;
P/= 2;
}
fout << res << '\n';
return 0;
}