Cod sursa(job #1657787)
Utilizator | Data | 20 martie 2016 19:59:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,r=1999999973,x,y,z;
int main(){
fin>>n>>p;
z=1;
x=p;
y=n;
while(x){
if(x%2){
z=(z*y)%r;
}
x=x/2;
y=(y*y)%r;
}
fout<<z;
fout.close();
fin.close();
return 0;
}