Cod sursa(job #1787588)
Utilizator | Data | 24 octombrie 2016 20:16:43 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | 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,x,M;
int cif;
int main()
{
fin>>N>>P;
M=1999999973;
q=1;
x=N;
while(P!=0)
{
cif=P%2;
if(cif==1)
{
q=(q*x)%M;
}
x=(x*x)%M;
P=P/2;
}
fout<<q;
return 0;
}