Cod sursa(job #1516008)

Utilizator shpincCandrea Laurentiu Vasile shpinc Data 2 noiembrie 2015 16:42:12
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.48 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");

const int MOD = 1999999973;

long long int LgPower(long long int x,long long int power){

    if(power==1){
        return x;
    }
    long long int k = LgPower(x, power / 2);
    k = (k * k) %  MOD;
    if(power % 2 == 1){
        k = (k * x) % MOD;
    }
    return k;

}


int main()
{
    int a,b;
    f>>a>>b;
    g << LgPower(a, b);


    return 0;
}