Cod sursa(job #1870312)

Utilizator ciocirlanrCiocirlan Robert ciocirlanr Data 6 februarie 2017 15:57:45
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 kb
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");

//#define mod 1999999973
const int mod = 1999999973;

int power(int a , int b){
    if(b == 0)return 1;
    if(b%2)return (1LL*a*power(a,b-1))%mod;
    int v = (1LL*power(a,b/2))%mod;
    return (1LL*v*v)%mod;
}

int a,b;
int main()
{
    f >> a >> b;
    g << power(a,b);
    return 0;
}