Cod sursa(job #2702154)

Utilizator DragosC1Dragos DragosC1 Data 2 februarie 2021 23:52:44
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <fstream>
using namespace std;

const int MOD = 1999999973;

int main() {
    long long a, b, P = 1;

    ifstream f("lgput.in");
    f >> a >> b;
    f.close();

    while (b) {
        if (b % 2 != 0)
            P = (P * a) % MOD;
        a = (a * a) % MOD;
        b /= 2;
    }

    ofstream g("gput.out");
    g << P;
    g.close();

    return 0;
}