Cod sursa(job #971195)

Utilizator superman_01Avramescu Cristian superman_01 Data 8 iulie 2013 18:30:22
Problema Ridicare la putere in timp logaritmic Scor 10
Compilator cpp Status done
Runda Arhiva educationala Marime 0.28 kb
#include<fstream>


using namespace std;

ifstream f("lgput.in");
ofstream g("lgput.out");

int N,P;

unsigned long long Sol;

int main ( void )
{
	f>>N>>P;
	Sol=1;
	
	while ( P )
	{
		if( P&1 )
			Sol=Sol*N;
	N*=N;
	P>>=1;
	}
	g<<Sol;
	f.close();
	g.close();
}