Cod sursa(job #897931)
Utilizator | Data | 27 februarie 2013 23:02:22 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
long long n,p,e;
fin>>n;
fin>>e;
p=n;
e--;
while(e>1)
{
if(e%2==0){p=p*p%1999999973;e=e/2;}
else {p=p*n%1999999973;e--;}
p=p%1999999973;
}
fout<<p<<'\n';
return 0;
}