Cod sursa(job #3267467)
| Utilizator | Data | 11 ianuarie 2025 12:05:18 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <iostream>
#include <fstream>
#define int long long
using namespace std;
int mod = 1999999973;
int exp(int A, int N) {
if (N == 1) return A;
if (N == 0) return 1;
if (N % 2 == 0) {
int aux = exp(A, N / 2);
return (aux * aux) % mod;
}
if (N % 2 == 1) {
int aux = exp(A, N / 2);
return ((aux * aux) % mod * A) % mod;
}
}
signed main() {
ifstream cin("lgput.in");
ofstream cout("lgput.out");
int a, b;
cin >> a >> b;
cout << exp(a, b);
return 0;
}
