Cod sursa(job #874829)
Utilizator | Data | 9 februarie 2013 12:57:17 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define M 1999999973
int main()
{
long long n,p,a;
fin>>n>>p;
a=1;
while(p>0)
if(p%2==0) {n=(n*n) % M; p/=2;}
else {a=(a*n) % M; --p;}
fout<<a;
fout.close();
return 0;
}