Cod sursa(job #2602644)
Utilizator | Data | 17 aprilie 2020 16:06:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
using namespace std;
long long b,e,mod=1999999973;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long exp(long long x,long long y){
if(!y)
return 1;
if(y%2)
return (x%mod*exp((x%mod*x%mod)%mod,(y-1)/2)%mod)%mod;
return exp((x%mod*x%mod)%mod,y/2)%mod;
}
int main(){
fin>>b>>e;
fout<<exp(b,e);
return 0;
}