Cod sursa(job #1098645)
Utilizator | Data | 4 februarie 2014 23:14:59 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include<fstream>
using namespace std;
const int mod=1999999973;
long long n,p,rez;
int main(void) {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
fin>>n>>p;
rez=1;
while (p>0)
if (p%2==0) { n*=n; n%=mod; p/=2; }
else { rez*=n; rez%=mod; --p; }
fout<<rez;
return(0);
}