Cod sursa(job #2422721)

Utilizator MariusblockMoga Marius-Ioan Mariusblock Data 19 mai 2019 19:10:40
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <bits/stdc++.h>
#define MOD 1999999973
#define ull unsigned long long

using namespace std;

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

ull powlog(ull x,ull n){
    ull P = 1;
    while(n){
        if(n%2){
            P = (P*x)%MOD;
        }
        x = (x*x)%MOD;
        n/=2;
    }
    return P;
}

int main()
{
    ull a,b;
    fin>>a>>b;
    fout<<powlog(a,b)<<endl;
    return 0;
}