Cod sursa(job #2428859)
Utilizator | Data | 6 iunie 2019 18:27:47 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
int main(){
long long n,p,r=1,x=1999999973;
fin>>n>>p>>x;
while(p){
if(p%2==1){
r=(r*n)%x;
}
n=(n*n)%x;
p=p/2;
}
fout<<r;
return 0;
}