Cod sursa(job #1614980)
Utilizator | Data | 26 februarie 2016 12:34:30 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
#define MOD 1999999973
int s,i;
long long n,p;
int main()
{ fin>>n;
fin>>p;
s=1;
while(p>0)
{
if(p%2==1) {s=(s*n)%MOD;}
n=(n*n)%MOD;
p=p/2;
}
fout<<s;
return 0;
}