Cod sursa(job #2751651)

Utilizator Summer05Cocut Alexandru Summer05 Data 15 mai 2021 14:41:38
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.37 kb
#include <bits/stdc++.h>
#define mod 1999999973

using namespace std;

ifstream fin("lgput.in");
ofstream fout("lgput.out");

int main()
{
    long long n,p,rez;
    fin >> n >> p;
    rez = 1;
    while(p)
    {
        if(p%2 == 1)
            rez = rez * n % mod;
        n = n * n % mod;
        p /= 2;
    }

    fout << rez;

    return 0;
}