Inverse Binomial Coefficient
The binomial coefficient C(N, K) is defined as N! / K! / (N − K)! for 0 ≤ K ≤ N. Here N! = 1 * 2 * ... * N for N ≥ 1, and 0! = 1. You are given integers n and R. You need to find the smallest K in the range {0, 1, ..., 2n − 1}, for which C(2n − 1, K) mod 2n = R. Here A mod B denotes the remainder of the division of A by B. If no such K exists output -1. Input The first line of the input conta
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start