title: Calculate multinomial coefficient
body: <p>I want to calculate multinomial coefficient mod 1e9 + 7. It equals: n! / (k0! * k1! * k2 * ... * km!)</p>
  
  <p>In my case m = 3, k0 + k1 + k2 = n, so it would be: n! / (k0! * k1! * k2!) My code for this:</p>
  
  <pre><code>....
  long long k2 = n - k1 - k0;
  long long dans = fact[n] % MOD;
  long long tmp = fact[i] % MOD;
  tmp = (tmp * fact[j]) % MOD;
  tmp = (tpm * fact[k]) % MOD;
  res = (fact[n] / tmp) % MOD; // mb mistake is here...
  cout &lt;&lt; res;
  </code></pre>
  
  <p>fact[i] - factorial of i mod 1e9+7
  It does not work on big tests</p>