Cod sursa(job #3221242)
Utilizator | Data | 6 aprilie 2024 13:11:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long N,P,Q,cif,x;
int main()
{
fin>>N>>P;
Q=1;
x=N;
do
{
cif=P%2;
if(cif==1)
{
Q=Q*x%1999999973;
}
x=x*x%1999999973;
P=P/2;
}while(P);
fout<< Q;
return 0;
}