Cod sursa(job #2366012)

Utilizator qwerty1234qwerty qwerty1234 Data 4 martie 2019 18:02:16
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.42 kb

#include <bits/stdc++.h>


using namespace std;

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

const int M = 1999999973;

int n , p;



int main()
{
    int ans = 1;
    fin >> n >> p;
    while(p)
    {
        if(p & 1)
            ans = 1LL * ans * n % M;
        p /= 2;
        n = 1LL * n * n % M;
    }
    fout << ans << "\n";
    fin.close();
    fout.close();
    return 0;
}