Cod sursa(job #2646817)

Utilizator teofilotopeniTeofil teofilotopeni Data 2 septembrie 2020 08:46:36
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.43 kb
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

long long Putere(int x, int y)
{
	int rez = x;
	while (y > 1)
	{
		rez = (rez * x) % 1999999973;
		y--;
	}
	return rez;
}

int main() {
	freopen("lgput.in","r",stdin);
	freopen("lgput.out","w",stdout);

	int n, p;
	scanf("%d %d", &n, &p);

	long long sol = Putere(n, p);
	printf("%lld\n", sol);
	return 0;
}