Cod sursa(job #1495491)
Utilizator | Data | 3 octombrie 2015 10:23:33 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin("lgput.in");
long long rasp=1,pn;
int n,p,i,cif;
fin>>n>>p;
pn=n;
do
{
cif=p%2;
p/=2;
if(cif)
rasp=rasp*pn%1999999973;
pn=pn*pn%1999999973;
}while(p);
ofstream fout("lgput.out");
fout<<rasp;
return 0;
}