Cod sursa(job #3350657)

Utilizator Alex_at_gameIustin-Alexandru Frateanu Alex_at_game Data 11 aprilie 2026 16:34:18
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.84 kb
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(v) begin(v), end(v)
#define al(v, l, r) begin(v) + l, begin(v) + r + 1
#define sz(v) (int)v.size()
#define pb push_back
#define pob pop_back
#define fs first
#define sd second

constexpr int inf = 2e9;
constexpr ll infll = 4e18;
constexpr int mod = 1999999973;

int pwr(int b, int e) {
    int r = 1;

    while (e) {
        if (e & 1) {
            r = (1ll * r * b) % mod;
        }

        b = (1ll * b * b) % mod;
        e >>= 1;
    }

    return r;
}

int n, p;
signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    freopen("lgput.in", "r", stdin);
    freopen("lgput.out", "w", stdout);

    cin >> n >> p;
    cout << pwr(n, p) << "\n";
}