#C6352. Fuel Efficiency Calculator

    ID: 50103 Type: Default 1000ms 256MiB

Fuel Efficiency Calculator

Fuel Efficiency Calculator

You are given a trip with several legs. For each leg, you are provided with two lists: one contains the distances traveled (in kilometers) and the other contains the fuel consumed (in liters). Your task is to compute the fuel efficiency for each leg using the formula: $$\text{efficiency}_i = \frac{\text{distance}_i}{\text{fuel}_i}$$. If either of the following conditions is true, output an empty result:

  1. The two lists have different lengths.
  2. Either list is empty (i.e. there are no legs of the trip).
  3. Any fuel value is zero (to avoid division by zero).

The input is read from standard input (stdin) and the result (the list of fuel efficiencies) should be printed to standard output (stdout) with values separated by a space. If the result is empty, print nothing.

inputFormat

The input is given in three lines:

  • The first line contains an integer n indicating the number of legs.
  • The second line contains n space-separated positive integers representing the distances traveled (in kilometers).
  • The third line contains n space-separated positive integers representing the fuel consumed (in liters).

If n is 0, or if the number of distances does not match the number of fuel values, then the output should be empty.

outputFormat

If the input is valid and none of the fuel values is zero, print a single line with the fuel efficiency for each leg, computed as distance / fuel. The efficiencies must be printed in the same order as the input values, separated by a single space. If any condition is violated (different lengths, empty lists, or a zero fuel value), print nothing.

## sample
3
100 200 150
10 20 15
10.0 10.0 10.0