#P2833. Counting Integer Solutions of a Linear Equation
Counting Integer Solutions of a Linear Equation
Counting Integer Solutions of a Linear Equation
You are given integers \(a, b, c, x_1, x_2, y_1, y_2\). Your task is to count the number of integer solution pairs \((x, y)\) such that:
\[ ax+by+c=0, \]
with \(x \in [x_1, x_2]\) and \(y \in [y_1, y_2]\). The coefficients and boundaries can be any integers.
If there is no solution, output 0.
inputFormat
The input consists of a single line containing 7 space-separated integers:
a b c x1 x2 y1 y2
Here, the equation is \(ax+by+c=0\) and \(x\) is in \([x1, x2]\), \(y\) is in \([y1, y2]\).
outputFormat
Output a single integer representing the number of integer solution pairs \((x, y)\) that satisfy the conditions.
sample
1 1 -5 0 5 0 5
6