Cod sursa(job #2564018)

Utilizator AlexPascu007Pascu Ionut Alexandru AlexPascu007 Data 1 martie 2020 17:02:36
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.32 kb
#include <bits/stdc++.h>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
long long n,p,sol;
int main() {
    fin>>n>>p;
    sol=1LL;
    while (p) {
        if (p&1)
            sol=sol*n%mod;
        n=n*n%mod;
        p>>=1;
    }
    fout<<sol;
    return 0;
}