Cod sursa(job #3130607)
Utilizator | Data | 18 mai 2023 09:00:12 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
const unsigned long long MOD = 1999999973;
unsigned long long n, p, result = 1;
fin>>p>>n;
while (n) {
if (n%2) result = (1ll*result*p)%MOD;
p = (1ll*p*p)%MOD;
n /= 2;
}
fout<<result%MOD;
return 0;
}