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.
Submitting an official solution before solving the problem yourself is a bannable offence.
- Sort all
s and
s
- Find all prime numbers up to max
and
, 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
.
- Find the result by repeated division by smaller and smaller factorials
Comments