Cod sursa(job #3355094)
| Utilizator | Data | 21 mai 2026 18:59:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int lg_put(int a, int b) {
int rez = 1;
while(b > 0) {
if(b % 2 == 1) {
rez = 1LL * rez * a % 1999999973;
}
a = 1LL * a * a % 1999999973;
b /= 2;
}
return rez;
}
int main(){
int a,b;
fin>>a>>b;
int rez = lg_put(a,b);
fout<<rez;
return 0;
}