시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB376865628.141%

문제

아래와 같이 물음표를 포함한 부등식이 있다.

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

이때, 부등식이 성립하게 물음표를 양의 정수로 바꾸는 경우의 수는 모두 몇 개가 있을까?

입력

첫째 줄에 B, C, D가 주어진다. (1 ≤ B, C, D ≤ 1000)

둘째 줄에 A1, A2가 주어진다. (1 ≤ A1, A2 ≤ 1000)

셋째 줄에 E1, E2가 주어진다. (1 ≤ E1, E2 ≤ 1000)

출력

첫째 부등식을 만족하게 물음표를 양의 정수로 바꾸는 방법의 수를 출력한다.

예제 입력 1

3 2 4
2 7
4 5

예제 출력 1

1

예제 입력 2

5 5 5
999 1
1000 1

예제 출력 2

4

예제 입력 3

1 9 7
14 5
10 3

예제 출력 3

3

힌트

세 번째 예제의 경우 다음과 같이 3가지 방법이 있다.

\[\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}\]

W3sicHJvYmxlbV9pZCI6IjMxMTAiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJkODBcdWI0ZjFcdWMyZGQiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YzU0NFx1Yjc5OFx1YzY0MCBcdWFjMTlcdWM3NzQgXHViYjNjXHVjNzRjXHVkNDVjXHViOTdjIFx1ZDNlY1x1ZDU2OFx1ZDU1YyBcdWJkODBcdWI0ZjFcdWMyZGRcdWM3NzQgXHVjNzg4XHViMmU0LjxcL3A+XHJcblxyXG48cD5cXFtcXGZyYWN7QV8xfXtBXzJ9ICZsdDsgXFxmcmFjez99e0J9ICZsdDsgXFxmcmFjez99e0N9ICZsdDsgXFxmc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