Cod sursa(job #1348187)
Utilizator | Data | 19 februarie 2015 16:00:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long P,p,r;
long long N;
fin>>N;
fin>>P;
p=1;
while(P!=0)
{
if(P%2!=0)
{
p=(p*N)%1999999973;
}
N=(N*N)%1999999973;
P=P/2;
}
fout<<p;
return 0;
}