Cod sursa(job #2986691)

Utilizator IandruIanis Ianachis Iandru Data 28 februarie 2023 22:26:39
Problema Ridicare la putere in timp logaritmic Scor 30
Compilator cpp-32 Status done
Runda Arhiva educationala Marime 0.36 kb
#include <iostream>
#include <fstream>

using namespace std;

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

int log(long long x,long long n)
{
    long long f=x;
    while(n!=1)
    {
        f=(f*x)% 1999999973;
        n--;
    }
    return f%1999999973;
}

int main()
{
    int N,P;
    fin>>N>>P;
    fout<<log(N,P);
    return 0;
}