Cod sursa(job #733837)

Utilizator Theorytheo .c Theory Data 13 aprilie 2012 02:30:53
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.49 kb
#include<fstream>
#define ll unsigned long long int
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
ll a,b,n,p;

ll rid( ll n, ll p )
{
	if( p == 1)
		return n %mod;

	if(p % 2 == 0 )
	{
		ll t = rid( n , p/2 ) % mod;
		return (t * t ) % mod ;
	}
	else
		return rid( n, p-1) %mod  * n%mod;

}
void cit()
{
	fin >> n >> p;
	fout << rid( n , p ) % mod;

}
int main()
{
	cit();
	fin.close();
	fout.close();
	return 0;
}