#include #include #include #include #include #include #include #include #include int64_t p = 998244353; std::vector factorials; std::vector invfactorials; int64_t modinverse(int64_t a) { int power = p - 2; int64_t base = a; int64_t answer = 1; while (power > 0) { if (power % 2) answer = (answer * base) % p; base = (base * base) % p; power /= 2; } return answer; } int main() { int n, k, m; std::cin >> n >> k >> m; int maxfac = 5000100; factorials.resize(maxfac + 2); invfactorials.resize(maxfac + 2); factorials[0] = 1; invfactorials[0] = 1; int64_t fac = 1; for (int64_t i = 1; i <= maxfac+1; i++) { fac = (fac * i) % p; factorials[i] = fac; } invfactorials[maxfac+1] = modinverse(factorials[maxfac+1]); for(int64_t i = maxfac; i >= 1; i--) { invfactorials[i] = (invfactorials[i+1] * (i+1) ) % p; } if (n > m || k > 64) { std::cout << 0 << std::endl; return 0; } int64_t totways = 0; // inclusion-exclusion coefficients std::vector ci(64); for (int i = 0; i < k; i++) { ci[i] = 0; } for (int i = 0; k + i < 64; i++) { int64_t c = 1; for (int j = 0; j < i; j++) { int64_t sub = factorials[k + i] * invfactorials[k + j] % p; sub = (sub * invfactorials[i - j]) % p; sub = (sub * ci[k + j]) % p; c = (p + c - sub) % p; } ci[k+i] = c; } for (int i = 0; i <= m; i++) { // to compute g(i): compute the most significant bit in i that is clear in m. Call it b. // Take the part of m that's more significant than b, delete from it all bits that are set in i. This is the prefix. // Count the number of bits that are less significant than b that are not set in i. This is suffixbits. // g(i) = prefix * 2^suffixbits. // (special case: if b does not exist, answer is (prefix+1)). int bits = 0; int64_t prefix = 0; int suffixbits = 0; bool computingprefix = true; for (int j = 63; j >= 0; j--) { bool skip = false; if (i & (1ULL << j)) { bits++; if (computingprefix) { if (m & (1ULL << j)) { skip = true; } else { computingprefix = false; } } } else { if (!computingprefix) suffixbits++; } if (computingprefix && !skip) { prefix *= 2LL; if (m & (1ULL << j)) prefix++; } } int64_t choices; if (computingprefix) choices = prefix + 1; else choices = prefix * (1LL << suffixbits); if (choices >= n) { int64_t choicesCn = (factorials[choices] * invfactorials[choices - n]) % p; //wait reordering is allowed now? //choicesCn = (choicesCn * invfactorials[n]) % p; choicesCn = (ci[bits] * choicesCn) % p; totways = (totways + choicesCn) % p; } } std::cout << totways << std::endl; }