Editorial for ICPC NEERC 2010 F - Factorial Simplification


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.
  • Sort all ps and qs
  • Find all prime numbers up to max p and q, and also find the next prime number after that
  • Compute the formula using representation of all numbers as products of primes in some power
    • Multiplication of numbers adds the powers
    • Division of numbers subtracts the powers
  • The largest factorial factor in the result can be as large as the next prime minus 1.
    • Find the result by repeated division by smaller and smaller factorials

Comments

There are no comments at the moment.