Pagini recente » Cod sursa (job #2768416) | Cod sursa (job #1396518) | Cod sursa (job #414183) | Cod sursa (job #673393) | Cod sursa (job #1921210)
#include <iostream>
#include <fstream>
using namespace std;
#define MOD 1999999973
ifstream f ("lgput.in");
ofstream t ("lgput.out");
inline void fasterLLDivMod(unsigned long long x, unsigned y, unsigned &out_d, unsigned &out_m) {
unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
#ifdef __GNUC__
asm(
"divl %4; \n\t"
: "=a" (d), "=d" (m)
: "d" (xh), "a" (xl), "r" (y)
);
#else
__asm {
mov edx, dword ptr[xh];
mov eax, dword ptr[xl];
div dword ptr[y];
mov dword ptr[d], eax;
mov dword ptr[m], edx;
};
#endif
out_d = d; out_m = m;
}
//x / y < 2^32 !
inline unsigned fasterLLMod(unsigned long long x, unsigned y) {
unsigned dummy, r;
fasterLLDivMod(x, y, dummy, r);
return r;
}
///ceva = fasterLLMod(numar,mod);
uint64_t lgput(uint64_t base,uint64_t exponent){
uint64_t n=1;
for (;exponent;exponent>>=1){
if (1&exponent)
n=fasterLLMod(n*base,MOD);
base=fasterLLMod(base*base,MOD);
}
return n;
}
int main()
{
uint64_t n,p;
f>>n>>p;
t<<lgput(n,p);
return 0;
}