Cod sursa(job #1913123)

Utilizator adiXMGemene Adrian adiXM Data 8 martie 2017 11:49:39
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.46 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int mod = 1999999973;
inline int Put(long long x, long long y) {
    int p = 1;
    while(y) {
        if(y & 1) {
            p = (1LL* p * x) % mod;
            y--;
        }
        x = (1LL * x * x) % mod;
        y = y / 2;
    }
    return p;
}
int main()
{
    long long x, n;
    f >> x >> n;
    g << Put(x, n) << "\n";
    return 0;
}