Cod sursa(job #2469699)
| Utilizator | Data | 7 octombrie 2019 21:13:57 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
#define NRSPEC 1999999973
#define ll long long
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll pt(ll nr,int exp){
ll rez=1;
for(int i=0;(1<<i)<=exp;i++){
if(((1<<i)&exp)>0)
rez=(rez*nr)%NRSPEC;
nr=(nr*nr)%NRSPEC;
}
return rez;
}
int main(){
int nr,exp;
//ll nr;
fin>>nr>>exp;
pt(nr,exp);
fout<<pt(nr,exp);
return 0;
}
