Cod sursa(job #2336226)

Utilizator ewaldBerla Ewald ewald Data 4 februarie 2019 21:53:31
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
#include <iostream>
using namespace std;

ifstream fin("lgput.in");
ofstream fout("lgput.out");

const int MOD = 1999999973;

int power(int x,int y){
    int r=1;
    while(y){
        if(y%2 == 1)
            r = (1LL*r*x)% MOD;
        x=(1LL*x*x)% MOD;
        y/=2;
    }
    return r;
}

int main()
{
    int x, y;
    fin>>x>>y;
    int r=power(x,y);
    fout<<r;
    return 0;
}