Cod sursa(job #2851584)

Utilizator SlavicGGuzun Veaceslav SlavicG Data 18 februarie 2022 20:35:56
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.87 kb
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
 
#define       forn(i,n)              for(int i=0;i<n;i++)
#define          all(v)              v.begin(), v.end()
#define         rall(v)              v.rbegin(),v.rend()
 
#define            pb                push_back
#define          sz(a)               (int)a.size()

const ll mod = 1999999973;

ll pw(ll a, ll b){
    ll r = 1;
    while(b) {
        if(b&1) {
            r = (r * a) % mod;
        }
        b /= 2;
        a = (a * a) % mod;
    }
    return r;
}
void solve() {
    ll a,b;
    cin >> a >> b;
    cout << pw(a, b) << "\n";
} 
 
int32_t main() {
    freopen("lgput.in", "r", stdin);
    freopen("lgput.out", "w", stdout);
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    //cin >> t;
    while(t--) {
        solve();
    }
}