Cod sursa(job #1101009)
Utilizator | Data | 7 februarie 2014 19:45:05 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream>
using namespace std;
ifstream oin("lgput.in");
ofstream oiut("lgput.out");
const long constanta = 1999999973;
long long n,p,sol=1;
int main()
{
oin>>n>>p;
while(p){
if(p%2==1) sol=(sol*n)%constanta;
n=(n*n)%constanta;
p=p/2;
}
oiut<<sol;
return 0;
}