Cod sursa(job #3135196)

Utilizator sebuxSebastian sebux Data 2 iunie 2023 12:02:31
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.77 kb
#include <bits/stdc++.h>
#define optim ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define let auto
#define popcount __builtin_popcount
#define ctzll __builtin_ctzll
#define clzll __builtin_clzll

using namespace std;

ifstream fin("lgput.in");
ofstream fout("lgput.out");


const ull mod = 1999999973;
ull POW(ull x, ull p){
    if(p == 0) return 1;
    if(p == 1) return x;

    if(p % 2 == 0){
        ull n = POW(x, p/2);
        return (n * n) % mod;
    }
    else {
        ull n = POW(x, p - 1);
        return (x * n) % mod;
    }
}



int main()
{
    ull a, b;
    fin>>a>>b;
    fout<<POW(a, b);



    return 0;
}