Cod sursa(job #1259194)

Utilizator GrandmasterSoucup Bogdan Grandmaster Data 9 noiembrie 2014 20:01:21
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.42 kb
#include<iostream>
#include<fstream>
#define MOD 1999999973LL
#define LL long long
using namespace std;
ifstream g("lgput.in");
ofstream f("lgput.out");
LL power(LL b, LL e)
{
	LL variabila;
	if(e == 0)
		return 1;
	if(e % 2 == 0)
	{
		variabila = power(b, e/2);
		return (variabila * variabila) % MOD;
	}
	else
		return (b * power(b, e - 1)) % MOD;
}
int main()
{
	int b, e;
	g >> b >> e;
	f << power(b, e);
}