Cod sursa(job #3310091)

Utilizator Darius9705Darius boros Darius9705 Data 11 septembrie 2025 17:52:14
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.69 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)%1999999973;
			p=p/2;
		}
		else
		{
			rez=(rez%1999999973*n)%1999999973;
			n=(n*n)%1999999973;
			p=p/2;
		}
	}
	fout<<rez%1999999973;
	return 0;
}