Cod sursa(job #2562337)

Utilizator Stefan_BircaBirca Stefan Stefan_Birca Data 29 februarie 2020 13:32:06
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <bits/stdc++.h>

using namespace std;

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

int P(int a, int b, int c)
{
    int p = 1;
    while (b != 0)
    {
        if (b % 2 == 1)
        {
            p = 1LL * p * a % c;
        }
        a = 1LL * a * a % 1999999973;
        b /= 2;
    }
    return p;
}

int main()
{
    long long n , m;
    fin >> n >> m;
    fout << P(n , m , 1999999973);
    return 0;
}