Cod sursa(job #3124434)

Utilizator victor_gabrielVictor Tene victor_gabriel Data 28 aprilie 2023 18:11:10
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>

using namespace std;

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

const int MOD = 1999999973;
long long n, p;

long long fastExp(long long a, long long b) {
    long long result = 1;
    while (b != 0) {
        if (b & 1)
            result = result * a % MOD;
        a = a * a % MOD;
        b /= 2;
    }
    return result;
}

int main() {
    fin >> n >> p;
    fout << fastExp(n, p);
    return 0;
}