Cod sursa(job #1569787)
Utilizator | Arvat Ovidiu Daniel iDanyel | Data | 15 ianuarie 2016 21:59:31 |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
int n, x;
long p;
p=1;
f >> x >> n;
while(n>0)
{
if(n%2!=0)
{
p*=x;
n--;
}
x*=x;
n=n/2;
}
g << p%1999999973;
f.close();
g.close();
return 0;
}