Cod sursa(job #2848503)
| Utilizator | Data | 12 februarie 2022 18:19:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
const int mod = 1999999973;
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int rid(long long b, long long exp) {
long long rez = 1;
while (exp) {
if (exp % 2 == 1)
rez = (rez * b) % mod;
b = (b * b) % mod;
exp /= 2;
}
return rez;
}
int main() {
long long a, b;
cin >> a >> b;
cout << rid(a, b);
return 0;
}
