Cod sursa(job #2572983)

Utilizator BogdanRazvanBogdan Razvan BogdanRazvan Data 5 martie 2020 15:16:53
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 mod 1999999973

using namespace std;

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

void usain_bolt()
{
    ios::sync_with_stdio(false);
    fin.tie(0);
}

long long pwr(long long a, long long b)
{
    long long sol = 1;
    while(b > 0) {
        if(b & 1) sol = (sol * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return sol % mod;
}

int main()
{
    usain_bolt();

    long long a, b;

    fin >> a >> b;

    fout << pwr(a, b);
    return 0;
}