Cod sursa(job #2486736)

Utilizator andrei_C1Andrei Chertes andrei_C1 Data 3 noiembrie 2019 13:54:10
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.45 kb
#include <fstream>
#define mod 1999999973
#define LL long long

using namespace std;

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

int ridicareLog(LL a,LL b)
{
    int r=1;
        while(b)
        {
            if(b%2==1)
                r=(1LL*r*a)%mod;
            a=(1LL*a*a)%mod;
            b/=2;
        }
    return r;
}

int main()
{
    LL a,b;
        fin>>a>>b;
            fout<<ridicareLog(a,b);
    return 0;
}