Cod sursa(job #1387607)
Utilizator | Data | 14 martie 2015 15:05:35 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include<fstream>
using namespace std;
int cif;
long long n,a,p,q,x;
int main ()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
a=n%1999999973;
x=p;
q=1;
while(x!=0)
{
cif=x%2;
if(cif==1)
{
q=(q*a)%1999999973;
}
a=(a*a)%1999999973;
x=x/2;
}
fout<<q;
fin.close();
fout.close();
return 0;
}