Cod sursa(job #2884472)

Utilizator hobbitczxdumnezEU hobbitczx Data 3 aprilie 2022 19:02:46
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.54 kb
#include <bits/stdc++.h>
#define ll long long
using namespace std;

const string fisier = "lgput";

ifstream fin (fisier + ".in");
ofstream fout (fisier + ".out");

const int mod = 1999999973;

ll a , b;

ll solve (ll a , ll b){
    ll ans = 1;
    while (b > 0){
        if (b & 1){
            ans = (ans % mod) * (a % mod) % mod;
        }
        a = (a % mod) * (a % mod) % mod;
        b = b / 2;
    }
    return ans;
}

int main(){
    ios_base::sync_with_stdio(false);
    fin >> a >> b;
    fout << solve(a , b);
}