Cod sursa(job #2571608)

Utilizator Benten3000Alexandru Benteu Benten3000 Data 5 martie 2020 08:50:13
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.35 kb
#include <bits/stdc++.h>
#define MOD 1999999973
#define ll long long 
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll lgput(int n, int p)
{
	ll s = 1;
	while (p)
	{
		if (p % 2) s = (s * n) % MOD;
		n = (n * n) % MOD;
		p /= 2;
	}
	return s;
}
int main()
{
	ll n, p;
	fin >> n >> p;
	fout << lgput(n, p);
}