Cod sursa(job #1644195)
Utilizator | Data | 9 martie 2016 21:58:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
int lgput(long long x,int y)
{
int z=1;
while (y!=0)
{
if (y%2==0)
{
x=(x*x)%MOD;
y=y/2;
}
else
{
z=(z*x)%MOD;
y=y-1;
}
}
return z;
}
int main ()
{
int a,b;
cin>>a>>b;
int x=lgput(a,b);
cout<<x;
}