Cod sursa(job #2985904)
Utilizator | Data | 27 februarie 2023 12:45:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-32 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
long long N,P;
const int m=1999999973;
long long lg_put(long long x, long long p)
{
long long rez=1;
while(p)
{
if(p%2==1)
rez=((rez%m)*x)%m;
x=(x%m)*(x%m);
p=p/2;
}
return rez;
}
int main()
{
fin>>N>>P;
fout<<lg_put(N,P);
}