Cod sursa(job #701007)

Utilizator PetcuIoanPetcu Ioan Vlad PetcuIoan Data 1 martie 2012 13:05:49
Problema Ridicare la putere in timp logaritmic Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include<stdio.h>
#include<assert.h>

const int kmod = 1999999973;
long long base, exp, sol;

void read(){
    assert(freopen("lgput.in","r",stdin)!=NULL);
    scanf("%lld%lld",&base ,&exp);
}

long long power(int x, int y){
    if(y == 1)
        return x;
    return power(x, y / 2) * power(x, y - y / 2) % kmod;
}

void solve(){
    sol = power(base, exp);
}

void write(){
    assert(freopen("lgput.out","w",stdout)!=NULL);
    printf("%lld",sol);
}

int main(){
    read();
    solve();
    write();
    return 0;
}