Cod sursa(job #1291338)
Utilizator | Data | 12 decembrie 2014 18:31:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
ifstream in("lgput.in");
ofstream out("lgput.out");
int main()
{
long long x,y,rez;
in>>x>>y;
rez=1;
while(y!=0)
{
if(y%2==1)
{
rez=rez*x%1999999973;
y--;
}
if(y%2==0)
{
x=x*x%1999999973;
y=y/2;
}
}
out<<rez%1999999973;
return 0;
}