Блог пользователя RetiredAmrMahmoud

Автор RetiredAmrMahmoud, 8 лет назад, По-английски

So recently I was trying to solve this problem 100965F - Polynomial, the following blog contains spoilers.

The first approach was trying to represent the polynomial as x * (x + 1) * ... * (x + m — 1) and get the result using divide and conquer and FFT multiplication in which didn't fit in the time limit. So the second approach is to print just the polynomial which will give 0 but only for x coprime with m, but surprisingly it got accepted.

So how is this correct? and also how the checker for this problem is written?

  • Проголосовать: нравится
  • +16
  • Проголосовать: не нравится

»
8 лет назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

By CRT, we can consider every prime power in the factorization of m separately. Now note that:

xm - xm - φ(m) = xm - φ(m)(xφ(m) - 1)

If x is coprime with p, then the right factor is 0. If x is not coprime with p, then from the fact that m - φ(m) is greater than the exponent of p, then the left factor is 0. So the polynomial is 0 in every point.