Inequality
Time limit1sMemory limit128 MB
Count integer triples X, Y, Z with fixed denominators B, C, D that keep a chain of four strict fraction inequalities between two given bounds true.
- Level
Medium4 of 10
- Topics
- Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
Choose three positive integers X, Y, and Z for the question marks so that all parts of the inequality hold.
Find the number of ordered triples (X, Y, Z) that satisfy the inequality.
Input
The first line contains B, C, and D. (1 <= B, C, D <= 1000)
The second line contains A1 and A2. (1 <= A1, A2 <= 1000)
The third line contains E1 and E2. (1 <= E1, E2 <= 1000)
Output
Print the number of ordered triples (X, Y, Z) of positive integers that satisfy the inequality.
Hint
Every inequality is strict. A choice where two neighboring fractions have the same value does not satisfy the condition.