int main(int argc, char *argv[]) { llint b, c; scanf("%lld%lld", &b, &c); printf("%lld", fastPow(2, b, c)); getch(); return 0; }
static float applyExpo(float value, float expo) { // note: fastPow makes a small error, therefore result needs to be bound float exp = boundf(fastPow(1.00695f, expo), 0.5f, 2.0f); // magic number scales expo // so that // expo=100 yields value**10 // expo=0 yields value**1 // expo=-100 yields value**(1/10) // (pow(2.0,1/100)~=1.00695) if (value > 0.0f) { return boundf(fastPow(value, exp), 0.0f, 1.0f); } else if (value < -0.0f) { return boundf(-fastPow(-value, exp), -1.0f, 0.0f); } else { return 0.0f; } }
long long modInv_euler(long long x, long long m){ // must be gcd(x,m)==1 // phi is euler function: O(sqrt(x)) return fastPow(x, phi(m)-1, m); }
long long modInv(long long x, long long p){ return fastPow(x, p-2, p); }