Cod sursa(job #1875171)

Utilizator andreeainfo_dAndreea Dutulescu andreeainfo_d Data 10 februarie 2017 20:00:00
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include <bits/stdc++.h>
using namespace std;
long long x,y;
long long putere(long long x, long long y)
{
    long long p;
    p=1;
    while(y)
    {
        if(y%2==1)
        {
            p=p*x%1999999973;
            y--;
        }
        x=x*x%1999999973;
        y=y/2;
    }
    return p%1999999973;
}
int main()
{
    freopen("lgput.in","r",stdin);
    freopen("lgput.out","w",stdout);
    scanf("%lld%lld",&x,&y);
    printf("%lld",putere(x,y));
    return 0;
}