Cod sursa(job #1561567)
| Utilizator | Data | 4 ianuarie 2016 11:40:14 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include<iostream>
#include<fstream>
using namespace std;
const int MOD=1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lgput (int 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;
fin>>a>>b;
int x=lgput(a,b);
fout<<x;
}
