Cod sursa(job #1606344)

Utilizator VladuZ1338Vlad Vlad VladuZ1338 Data 20 februarie 2016 10:02:28
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.44 kb
#include <cstdio>

using namespace std;

long long x, y, mod=1999999973;

long long putere (long long x, long long y)
{
    if(y==1) return x;
    else if (y%2==0) return putere((x*x)%mod, y/2)%mod;
    else return (x*putere((x*x)%mod, y/2))%mod;
}

int main()
{
    freopen ("lgput.in", "r", stdin);
    freopen ("lgput.out", "w", stdout);
    scanf ("%lld%lld", &x, &y);
    long long sol=putere(x,y);
    printf ("%lld", sol);
}