Number of solutions
Time limit1sMemory limit256 MB
Count the integer pairs (x, y) inside the given x and y ranges that satisfy Ax + By + C = 0.
- Level
Medium5 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem
Write a program that counts the integer solutions of the equation .
, , , , and are all integers. Count the integer pairs that satisfy the equation with and .
If , , and are all , every integer pair inside the given ranges is a solution.
Input
The first line contains , , , , , , , separated by spaces. Every value is an integer between and , and , .
Output
Print the number of solutions on the first line. The count can exceed the range of a 32-bit integer.