Cod sursa(job #874958)
Utilizator | Data | 9 februarie 2013 15:02:20 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 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)%1999999973;
p=p/2;
}
else
{
aux=(aux*n)%1999999973;
p--;
};
g<<(aux*n)%1999999973;
return 0;
}