Cod sursa(job #1579501)
Utilizator | Data | 24 ianuarie 2016 20:15:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
long long N,P,pr=1;
f>>N>>P;
while(P>0)
{
if(P%2==1)
{
pr=(pr*N)%1999999973;
P--;
}
P=P/2;
N=(N*N)%1999999973;
}
g<<pr;
return 0;
}