Cod sursa(job #2047198)

Utilizator whitewolfJon Snow whitewolf Data 24 octombrie 2017 17:19:37
Problema Subsir crescator maximal Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.65 kb
#include <bits/stdc++.h>

using namespace std;

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

void Read() {
    ifstream fin("lgput.in");
    fin >> n >> p;
    fin.close();
}

long long Log_Pow(int base, int expo) {
    int ans = 1;
    while (expo) {
        if (expo % 2 == 0) {
            base = 1LL * base * base % modulo;
            expo /= 2;
        }
        expo--;
        ans = 1LL * ans * base % modulo;
    }
    return ans;
}

void Write() {
    long long ans = Log_Pow(n, p);
    ofstream fout("lgput.out");
    fout << ans << "\n";
    fout.close();
}

int main()
{
    Read();
    Write();
    return 0;
}