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

Автор Akhilanand0011, история, 4 года назад, По-английски
  • Проголосовать: нравится
  • +1
  • Проголосовать: не нравится

»
3 года назад, # |
  Проголосовать: нравится -7 Проголосовать: не нравится

The problem asks to count number of possible (x, y, z) such that Ax + By + Cz = P, where x, y, z >= 0. Also notice that C/gcd(A, B, C) ≥ 200.

If we iterate over all possible z, the problem simplifies to finding number of solutions for Ax + By = P - Cz, where minX = 0, maxX = (P - Cz) / B, minY = 0, maxY = (P - Cz) / A.

This is a linear diophantine equation. You can learn how to solve this here.