Cod sursa(job #874954)
Utilizator | Data | 9 februarie 2013 15:00:06 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,p,aux;
int main()
{
aux=1;
f>>n>>p;
while (p!=1)
if (p%2==0)
{
n=n*n;
p=p/2;
}
else
{
aux=aux*n;
p--;
};
g<<(aux*n)%1999999973;
return 0;
}