Cod sursa(job #1569781)
Utilizator | Arvat Ovidiu Daniel iDanyel | Data | 15 ianuarie 2016 21:55:37 |
---|---|---|---|
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, m, p = 1, x;
f >> x >> n;
m=1999999973;
while(n>0)
{
if(n%2!=0)
{
p*=x;
n--;
}
x*=x;
n=n/2;
}
g << p%m;
f.close();
g.close();
return 0;
}