Cod sursa(job #2293867)

Utilizator al3xionescuIonescu Alexandru al3xionescu Data 1 decembrie 2018 17:41:08
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
typedef long long Int;
const Int Mod = 1999999973LL;
Int n, p;
Int putere(Int b, Int e) {
    Int r = 1;
    for(;e;e /= 2) {
        if (e%2) {
            r = r * b % Mod;
        }
        b = b * b % Mod;
    }
    return r;
}
int main() {
    f >> n >> p;
    g << putere(n, p);
    return 0;
}