Cod sursa(job #2219925)
Utilizator | Antracod antracods | Data | 10 iulie 2018 00:13:04 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.57 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
const int modd = 1999999973;
long long int lgpowy(long long int x,long long int y)
{
long long int sol=x;
long long int aux=1;
while(y>0)
{
if(y%2==0)
{
sol=(sol*sol)%modd;
y=y/2;
}
else
{
y--;
aux=aux*x%modd;
}
}
return (sol*aux)%modd;
}
int main()
{
long long int x,y;
cin>>x>>y;
cout<<lgpowy(x,y-1);
}