Cod sursa(job #2929617)

Utilizator DKMKDMatei Filibiu DKMKD Data 26 octombrie 2022 12:38:25
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.39 kb
#include <bits/stdc++.h>
#define MOD 1999999973
#define N 30

using namespace std;

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

int n, p;
int Power(int n, int p) {
	if (p == 0) return 1;
	else if (p % 2 == 1)
		return (1Ll*n * Power(n, p - 1))%MOD;
	int P = Power(n, p / 2);
	return (1LL*P * P)%MOD;
}
int main() {
	fin >> n >> p;
	fout<<Power(n, p);
	return 0;
}