Cod sursa(job #3310087)

Utilizator Darius9705Darius boros Darius9705 Data 11 septembrie 2025 17:49:09
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
    long long n,p,i,j,rez=1;
    fin>>n>>p;
    while(p!=0)
    {
        if(p%2==0)
        {
            n=n*n;
            p=p/2;
        }
        else
        {
            rez=(rez*n)%1999999973;
            n=(n*2)%1999999973;
            p=p/2;
        }
    }
    fout<<rez;
    return 0;
}