Cod sursa(job #733834)

Utilizator Theorytheo .c Theory Data 13 aprilie 2012 02:04:04
Problema Ridicare la putere in timp logaritmic Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 1.86 kb
#include<fstream>

#define ll long long

#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;



	if(p % 2 == 0 )

	{

		ll t = rid( n , p/2 ) % mod;

		return (t * t ) % mod ;

	}

	else

		return rid( n, p-1) %mod ;



}

void cit()

{

	fin >> n >> p;

	fout << rid( n , p ) % mod;



}

int main()

{

	cit();

	fin.close();

	fout.close();

	return 0;

}