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