Pagini recente » Cod sursa (job #1765711) | Cod sursa (job #1092551) | Cod sursa (job #1697453) | Cod sursa (job #2689346) | Cod sursa (job #712506)
Cod sursa(job #712506)
#include <fstream>
using namespace std;
#define mod 1999999973
ifstream f("lgput.in");
ofstream g("lgput.out");
int main()
{
int baza, exponent, x, t=0, i, cifre[1000];
long long p=1;
f>>baza>>exponent;
x=exponent;
while(x)
{
cifre[t]=x%2;
t++;
x=x/2;
}
for(i=t-1; i>=0; i--)
{
if(cifre[i]%2==1)
{
p=((p*p)%mod*baza)%mod;
}
else
p=(p*p)%mod;
if(p>mod)
{
p=p%mod;
}
}
g<<p;
}