We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
It seems we can solve all test cases taking advantage of the symmetry of Pascal pyramid level. Every j element in row i (rows are enumarated from very bottom where i = 0 means bottom row) in level n of Pascal pyramid is given by the formula: n! / (i! * j! * (n - i - j)!). Due to symmetry we need to consider only one third of rows. Last but not least, it's very helpful to precompute given prime exponents in all factorials.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #154: Exploring Pascal's pyramid.
You are viewing a single comment's thread. Return to all comments →
It seems we can solve all test cases taking advantage of the symmetry of Pascal pyramid level. Every j element in row i (rows are enumarated from very bottom where i = 0 means bottom row) in level n of Pascal pyramid is given by the formula: n! / (i! * j! * (n - i - j)!). Due to symmetry we need to consider only one third of rows. Last but not least, it's very helpful to precompute given prime exponents in all factorials.