Editorial for ICPC NWERC 2011 A - Binomial Coefficients


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
  • Find n,k such that (nk)=n!k!(nk)!=x
  • Only look for solutions with kn2 and count twice if necessary
  • Approach 1:
    • Loop over k from 0 to (2kk)>x
    • Binary search for n
  • Approach 2:
    • For k=1, solution is (x1)
    • For k=2, solve x=(n2)=n(n1)2
    • For k3, loop over n until (nk)>x
  • Be really careful with overflows!

Comments

There are no comments at the moment.