Cod sursa(job #2646516)

Utilizator DormeoNoapte Buna Dormeo Data 1 septembrie 2020 13:25:21
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.44 kb
#include <bits/stdc++.h>
#define mod 1999999973

using namespace std;

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

long long exp(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()
{
    long long a, b;

    fin >> a >> b;
    fout << exp(a, b);
    return 0;
}