Under construction

Still being built. Things may change

Ride My Bicycle

Interview

Time limit1sMemory limit128 MB

Summary
Compute the ratio of each of the 21 front and back gear pairs, round to two decimals, and print them sorted by ratio then chain ring.
Level

Easy3 of 10

Topics
Sorting, Implementation, Math
Solved
No attempts yet

Problem

A bicycle has 3 chain rings on the crank (the gears attached to the pedals) at the front and 7 gears on the back wheel. The chain connects exactly one front chain ring to one back gear, and the derailleurs can switch the chain to any combination of the 3 front chain rings and 7 back gears, giving 3×7=213 \times 7 = 21 possible combinations.

The ease of pedalling is determined by the ratio of the number of teeth on the chosen chain ring to the number of teeth on the chosen back gear. The smaller this ratio, the easier it is to pedal. Given the number of teeth on each gear, write a program that reports the gear ratio for every combination.

Input

The input consists of two lines.

  • Line 1: three distinct positive integers separated by single spaces, in strictly increasing order, giving the number of teeth on each front chain ring. From smallest to largest they are chain rings 1, 2, and 3.
  • Line 2: seven distinct positive integers separated by single spaces, in strictly increasing order, giving the number of teeth on each back gear. From smallest to largest they are back gears 1 through 7.

You may assume that every gear ratio is less than 1010.

Output

Print 21 lines. Each line describes one combination and has the form

x.xx f b

  • f is the chain ring number (1≤f≤31 \le f \le 3),
  • b is the back gear number (1≤b≤71 \le b \le 7),
  • x.xx is (teeth on chain ring ff) / (teeth on back gear bb) rounded to two decimal places.

The three fields are separated by single spaces. Print the lines from smallest ratio to largest; if two or more ratios are equal, print the one with the smaller chain ring number first.

Examples1

  1. Example 1

    Input
    32 42 52
    12 15 17 18 21 24 28
    
    Expected output
    1.14 1 7
    1.33 1 6
    1.50 2 7
    1.52 1 5
    1.75 2 6
    1.78 1 4
    1.86 3 7
    1.88 1 3
    2.00 2 5
    2.13 1 2
    2.17 3 6
    2.33 2 4
    2.47 2 3
    2.48 3 5
    2.67 1 1
    2.80 2 2
    2.89 3 4
    3.06 3 3
    3.47 3 2
    3.50 2 1
    4.33 3 1