Cod sursa(job #2705843)
Utilizator | Data | 13 februarie 2021 13:37:14 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.37 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int64_t MOD=1999999973LL;
int64_t n,p,putere(int64_t,int64_t);
int main(){
f>>n>>p;
g<<putere(n,p);
}
int64_t putere(int64_t b, int64_t e){
if(e==0)
return 1LL;
int64_t r=putere(b,e/2);
r = r *r % MOD;
if(e%2==1)
r=r*b%MOD;
return r;
}