Cod sursa(job #3210972)

Utilizator gfxwdAndrei Clopot gfxwd Data 7 martie 2024 20:06:03
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("lgput.in");
ofstream g("lgput.out");

long long LgPut(int x, int n){
    if(n==0)
        return 1;
    if(n%2!=0)
        return x* LgPut(x*x, (n-1)/2);

    return LgPut(x*x, n/2);



}

int main()
{
    int n,p;
    f>>n>>p;

    long long x= LgPut(n,p);

    g<< x%1999999973;
    return 0;
}