Cod sursa(job #2764821)

Utilizator helloworld0107Iordachi Bianca helloworld0107 Data 22 iulie 2021 18:58:30
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.33 kb
#include <iostream>

using namespace std;


	freopen("lgput.in","r",stdin);
	freopen("lgput.out","w",stdout);

int main()
{
    long long n, p, s = 1;
    cin >> n >> p;
    while (p)
    {
        if (p % 2 == 1)
            s = s * n % 1999999973;
        n = n * n % 1999999973;
        p = p / 2;
    }
    cout << s;
    return 0;
}