Cod sursa(job #2345607)
Utilizator | Data | 16 februarie 2019 15:20:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
using namespace std;
int x,p;
long long int ans;
int main()
{
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>x>>p;
ans=1;
while (p!=0)
{
if (p%2==0)
{
x=x*x;
p=p/2;
}
else
{
ans=x*ans;
x=x*x;
p=(p-1)/2;
}
}
fout<<ans%1999999973;
return 0;
}