Cod sursa(job #3342797)
| Utilizator | Data | 25 februarie 2026 18:30:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream fin ("lgput.in");
ofstream fout("lgput.out");
const int MOD = 1999999973;
long long lgput (int b, int e, int mod){
long long p = 1;
while (e>0){
if(e%2==1){
p=1LL*p*b%mod;
}
b=1LL*b*b%mod;
e/=2;
}
return p;
}
int main(){
int b, e;
fin>>b>>e;
fout<<lgput(b, e, MOD);
return 0;
}