Cod sursa(job #2823758)

Utilizator RORO123bBarbulescu Robert RORO123b Data 29 decembrie 2021 16:44:59
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.3 kb
#include <fstream>

using namespace std;

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

int main()
{
	unsigned long int n, p, rez = 1;
	fin >> n >> p;
	for (p; p >= 1; p/=2)
	{
		if (p % 2 == 1)
			rez=(1LL * rez * n) % 1999999973;
		n=(1LL * n * n) % 1999999973;
	}
	fout << rez;
}