luogu#P5171. Earthquake

Earthquake

Problem Description

Given a,b,ca,\,b,\,c, find the number of non-negative integer solutions that satisfy the inequality ax+bycax+by \leqslant c.

Input Format

Input three integers a,b,ca,\,b,\,c.

Output Format

Output one integer representing the answer.

3 4 13
12

Hint

Sample Explanation:

Let (x,y)(x,\,y) represent a valid solution. The sample has the following 1212 valid solutions:

(0,0)(0,\,0), (0,1)(0,\,1), (0,2)(0,\,2), (0,3)(0,\,3), (1,0)(1,\,0), (1,1)(1,\,1), (1,2)(1,\,2), (2,0)(2,\,0), (2,1)(2,\,1), (3,0)(3,\,0), (3,1)(3,\,1), (4,0)(4,\,0).

Constraints:

Test point ID a,ba,\,b cc
151 \sim 5 10\leqslant 10
6106 \sim 10 105\leqslant 10^5 109\leqslant 10^9
112511 \sim 25 109\leqslant 10^9 1018\leqslant 10^{18}

For all testdata, $1 \leqslant a,\,b \leqslant 10^9,\ 0 \leqslant c \leqslant \min(a,\,b) \times 10^9$.

Translated by ChatGPT 5