Non-Alcoholic Cocktail

Interview

Time limit1sMemory limit128 MB

Summary
Given amounts of three juices and a mixing ratio, compute the leftover of each juice after making the maximum possible cocktail.
Level

Easy3 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Sanggeun and Jisu bought orange juice, apple juice, and pineapple juice at the store. Using a recipe they found online, they plan to make non-alcoholic cocktails to sell at school. Because they bought the juice before finding the recipe, some juice may be left over.

You are given the ratio of orange, apple, and pineapple juice needed to make a cocktail, together with the amount of each juice they bought. Write a program that, after making as much cocktail as possible (not necessarily a whole number of glasses — as much as the juice allows, continuously), reports how much of each juice is left over.

You mix the cocktail in the ratio orange : apple : pineapple =I:J:K= I : J : K. The largest amount of cocktail you can make corresponds to the multiplier t=min⁡(AI,BJ,CK)t = \min\left(\dfrac{A}{I}, \dfrac{B}{J}, \dfrac{C}{K}\right), and the leftover juice is then A−tIA - tI, B−tJB - tJ, and C−tKC - tK respectively.

Input

The first line contains the amounts of orange, apple, and pineapple juice bought, AA, BB, and CC. (1≤A,B,C≤5001 \le A, B, C \le 500)

The second line contains the ratio of each juice needed to make a cocktail, II, JJ, and KK. (1≤I,J,K≤501 \le I, J, K \le 50)

Output

Print, on one line separated by spaces, how much orange, apple, and pineapple juice is left after making as much cocktail as possible.

Round each value to 6 decimal places, then remove all trailing zeros from the fractional part (and the decimal point itself if the fractional part becomes empty). Thus integer values are printed without a decimal point, like 0, 3, 6, and non-integer values are printed like 1.666667. Print a negative zero (-0) as 0.

Examples3

  1. Example 1

    Input
    9 9 9
    3 2 1
    
    Expected output
    0 3 6
    
  2. Example 2

    Input
    10 10 10
    3 3 3
    
    Expected output
    0 0 0
    
  3. Example 3

    Input
    10 15 18
    3 4 1
    
    Expected output
    0 1.666667 14.666667