Cod sursa(job #937741)

Utilizator GrandmasterSoucup Bogdan Grandmaster Data 10 aprilie 2013 22:50:23
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include <fstream>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");

int main ()
{
	unsigned long long x, y , c = 1999999973ll, i, temp = 1ll, rez = 1ll;
	fin>>x>>y;
	temp = x;
	while(y!=0ll)
	{
		if(y % 2ll != 0)
			rez = (rez * temp) % c;
		temp = (temp * temp) % c;
		y /= 2ll;
	}
	fout<<rez;
	return 0;
}