Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

n choose k Function

Revision en1, by FluffyPotato, 2019-06-29 04:06:10

Hello world! There is a choose function in math like "A choose B" notated sometimes like aCb I'm wondering if you can calculate this in O(1) in a program. Given two a and b, calculate a choose b.

You can definitely precompute many values, in an O(ab) loop keeping the factorials, but Can you do it without precomputation? However, precomputing also risks long long overflow. (usually choosing is much lower then the direct factorial value) Thank you

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English FluffyPotato 2019-06-29 04:06:10 475 Initial revision (published)