Editorial for COCI '20 Contest 4 #2 Vepar


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.

For simplicity, replace the expression

a×(a+1)××bc×(c+1)××d

with the equivalent

(c1)!×b!(a1)!×d!

For each prime p, define the map vp(x) which returns the largest power of p which divides x.

The left-hand side divides the right-hand side if an only if: for each p, we have vp of the left-hand side is at most the vp of the right-hand side.

It's easy to see vp(xy)=vp(x)+vp(y). We now want only vp(x!).

Proposition: We have

vp(x!)=xp+xp2+xp3+

Proof: The first summand counts multiples of p, the second counts multiples of p2, and so on.

The solution is thus: find all primes up to 107, implement vp(x!), and check the relevant inequality of vp for each prime.


Comments

There are no comments at the moment.