Cod sursa(job #3207673)

Utilizator EdyIordacheIordache Eduard EdyIordache Data 26 februarie 2024 18:37:35
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 kb
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1999999973

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

int main() {
    int n, p, x;
    fin>>n>>p;

    x = 1;
    while (p) {
        if (p % 2 == 1) x = x * n % mod;
        n = n * n % mod;

        p /= 2;
    }

    fout<<x % mod;

    return 0;
}