Cod sursa(job #2718305)

Utilizator Stefan_XTRadu Stefan Rares Stefan_XT Data 8 martie 2021 17:34:12
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
#define ll long long
#define mod 1999999973
using namespace std;

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

int main()
{
    ll a, b;
    fin >> a >> b;

    ll rez = 1, x = a % mod;
    while(b)
    {
        if (b % 2 == 1) rez = (rez * x) % mod;
        x = (x * x) % mod;
        b /= 2;
    }
    fout << rez % mod;

    fin.close();
    fout.close();
    return 0;
}