Weekend Gardening

면접 대비

시간 제한1초메모리 제한1024 MB

요약
예산 범위 L부터 H까지, 세 가지 식물 가격과 재고 수량이 주어질 때, 무작위로 하나씩 골라 누적 금액이 범위를 유지할 확률을 구한다.
난이도

보통10점 중 7점

유형
확률, 동적 계획법, 조합론, 완전 탐색
정답자
아직 제출이 없습니다

문제

Your roommate is planning some weekend projects to make your yard look better. The plan is to buy some plants. Your roommate wants to spend at least L dollars and at most H dollars. There are three different types of plants: cheap, normal, and expensive. Unfortunately, you cannot tell the difference by just looking at a plant. You know that each type has a different cost, and you know how many of each type your local nursery has in stock.

Now you are spending your time walking through the nursery aisles, picking out a plant, bringing it over to be rung up by the clerk, and praying that you stay within your desired total cost (your allotted budget). If you are not within your desired total cost (i.e., if your total cost is too low or too high), your roommate will get frustrated.

Given the cost and number of each plant type along with your desired budget range, determine the probability that you can buy plants one at a time and staying within your total cost range.

입력

The first input line contains two integers: L and H (1 ≤ L ≤ H ≤ 109), representing the low and high end of the budget, respectively.

The second input line contains three integers: C, N, and E (1 ≤ C < N < E ≤ 109), representing the cost of the cheap, normal, and expensive plants, respectively.

The third input line contains three integers: c, n, and e (1 ≤ c, n, e ≤ 100), representing the number of cheap, normal, and expensive plants, respectively.

출력

Print the probability that you will successfully complete the purchase within the desired budget by choosing plants one at a time. Your answer will be accepted if it is within 10-6 of the correct answer.

예제2

  1. 예제 1

    입력
    30 60
    5 15 70
    3 1 1
    
    예상 출력
    0.2
    
  2. 예제 2

    입력
    40 60
    5 15 70
    3 1 1
    
    예상 출력
    0.0