Under construction

Still being built. Things may change

Binomial Coefficient

Time limit2sMemory limit512 MB

Summary
Given n (up to 10^18) and k, compute the binomial coefficient C(n, k) modulo 2^32.
Level

Hard8 of 10

Topics
Math, Number theory, Bit manipulation
Solved
No attempts yet

Problem

Given nn and kk, calculate (nk)=n!k!(n−k)! mod (232)\binom{n}{k} = \frac{n!}{k!(n - k)!} \bmod (2^{32}).

Input

Two integers nn and kk (1≤n≤1018,0≤k≤n1 \leq n \leq 10^{18}, 0 \leq k \leq n).

Output

A single integer, the value.

Examples2

  1. Example 1

    Input
    4 2
    
    Expected output
    6
    
  2. Example 2

    Input
    1000000000 500000000
    
    Expected output
    4209467392