Cod sursa(job #874836)
Utilizator | Data | 9 februarie 2013 12:59:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 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) {a=(a*n) % M; --p;}
else {n=(n*n) % M; p/=2;}
fout<<a;
fout.close();
return 0;
}