Pagini recente » Statistici Paiu Andreea (andreea_paiu) | Cod sursa (job #2280213)
#include <iostream>
#include <fstream>
#include <math.h>
#include <windows.h>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
long int k=1999999973;
long long int exp(long long int x,long long int y)
{
// x%=k;
cout<<"Intru in functie cu X="<<x<<" si Y="<<y<<endl;
system("PAUSE");
if(y==0)
{
return 1;
}
if(y%2)
{
return (long long)(x*exp(x*x,(y-1)/2));
}
return (long long)(exp( x*x,y/2));
}
int main()
{
long long int n,rez,p,x=0;
f>>n>>p;
// x=exp(n,p);
// g<<x;
rez=1;
while(p)
{
if(p%2)
{
rez=rez*n;
}
n=n*n;
p=p/2;
}
g<<rez%k;
}