Cod sursa(job #2230136)

Utilizator Alex03Runcan Alexandru Alex03 Data 9 august 2018 11:17:13
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("lgput.in"); ofstream fout ("lgput.out");
#define mod 1999999973;

int main ()
{
	long long n, k, p = 1LL;
	fin >> n >> k;
	n %= mod;
	while (k > 1LL)
		if (k&1) { p = (p * n) % mod; --k ;}
		else {n = (n * n) % mod; k /= 2;}
	fout << (n * p) % mod;
	return 0;
}