BERBA | 프로그래밍의 벗 PivotOJ
PivotOJ

BERBA

시간 제한: 1000ms메모리 제한: 128MB출처: CHC 2009 National Competition #1 - SeniorsBOJ 3110

문제

How many ways can the following inequality be satisfied if the question marks are replaced by positive integers? 

\[\frac{A_1}{A_2} < \frac{?}{B} < \frac{?}{C} < \frac{?}{D} < \frac{E_1}{E_2}\]

입력

The first line contains three integers B, C and D (1 ≤ B, C, D ≤ 1000). 

The second line contains two integers A1 and A2 (1 ≤ A1, A2 ≤ 1000). 

The third line contains two integers E1 and E2 (1 ≤ E1, E2 ≤ 1000). 

출력

Output the number of ways to satisfy the inequality. 

힌트

In the third example, the three ways to satisfy the inequality are:

\[\frac{14}{5} < \frac{3}{1} < \frac{28}{9} < \frac{22}{7} < \frac{10}{3}\]\[\frac{14}{5} < \frac{3}{1} < \frac{28}{9} < \frac{23}{7} < \frac{10}{3}\]\[\frac{14}{5} < \frac{3}{1} < \frac{29}{9} < \frac{23}{7} < \frac{10}{3}\]

예제

예제 1

입력
3 2 4
2 7
4 5
출력
1

예제 2

입력
5 5 5
999 1
1000 1
출력
4

예제 3

입력
1 9 7
14 5
10 3
출력
3
코드를 제출하려면 로그인하세요.