Cod sursa(job #758317)

Utilizator robertpoeRobert Poenaru robertpoe Data 15 iunie 2012 10:20:01
Problema Ridicare la putere in timp logaritmic Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.3 kb
#include<fstream>
#include<cstdio>
#define mod 1999999973
#define xxl long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
xxl x,y,sol=1;
int i;
int main()
{
	f>>x>>y;
	for(i=0;(1<<i)<=y;++i)
	{
		if((( 1<<i) & y)>0)
			sol=(sol*x)%mod;
		x=(x*x)%mod;
	}
	g<<sol;
}