Cod sursa(job #2573953)
Utilizator | Data | 5 martie 2020 19:41:15 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long MOD = 1999999973;
long long n, p, aux = 1;
int main()
{
fin>>n>>p;
while(p > 1)
{
if(p%2)
{
aux = (aux * n) % MOD;
}
n*=n;
n%=MOD;
p/=2;
}
fout<<(n*aux)%MOD;
fin.close();
fout.close();
return 0;
}