Cod sursa(job #303334)

Utilizator AndreiDDiaconeasa Andrei AndreiD Data 9 aprilie 2009 19:15:24
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.62 kb
#include <cstdio>

using namespace std;

#define FIN "lgput.in"
#define FOUT "lgput.out"
#define Mod 1999999973
#define ll long long 

ll a,b;

inline ll power(ll a, ll b)
{
	ll x;
	if (b==1)
		 return a;
	else
	if (b%2==0)
	{
		x=power(a,b/2);
		return ((x*x)%Mod);
	}
	else
	{
       x=power(a,b/2);
	   return ((((x*x)%Mod)*a)%Mod);
	}
}
inline void citire()
{
	freopen(FIN,"r",stdin);
	freopen(FOUT,"w",stdout);
	
	scanf("%lld %lld", &a,&b);
}

inline void scrie()
{
	printf("%lld", power(a,b));
}

int main()
{
	citire();
	scrie();
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
}