Cod sursa(job #427620)

Utilizator hendrikHendrik Lai hendrik Data 28 martie 2010 06:53:39
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.57 kb
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;

#define MOD 1999999973
typedef long long ll;
void open(){
    freopen("lgput.in","r",stdin);
    freopen("lgput.out","w",stdout);
}

ll a,b;
ll bigmod(ll a,ll b){
    if (b==0) return 1;
    if (b==1) return a%MOD;
    if (b%2==0){
        ll x=bigmod(a,b/2);
        return (x*x)%MOD;
    }
    return (a*bigmod(a,b-1))%MOD;
}

int main(){
    open();
    scanf("%lld%lld",&a,&b);
    printf("%lld\n",bigmod(a,b));
    //system("pause");
    return 0;
}