Take Your Vitamins

Time limit1sMemory limit128 MB

Summary
For each line of amount, unit, requirement, and name, print the rounded daily-value percentage; collect items under 1% into a trailing list.
Level

Easy3 of 10

Topics
Implementation, Math, Simulation, String
Solved
No attempts yet

Problem

Manufacturers of food products are required to place nutrition information labels on their packages. A major part of this information is a listing of important vitamins and minerals, giving both the amount of the chemical present in one serving and the percentage of an adult's minimum daily requirement for that chemical.

Write a program that helps prepare these nutrition labels by computing that percentage from the amount present in one serving and the amount that constitutes the minimum daily requirement.

Input

The input consists of one or more lines, each of the form:

A U R V

where:

  • A is the amount of a vitamin/mineral present in one serving of the food product,
  • U is the unit in which A is measured,
  • R is the minimum daily requirement for that vitamin/mineral, measured in the same unit as A,
  • V is the name of that vitamin/mineral.

A and R are floating-point numbers. U is a string of alphabetic characters with no embedded spaces. V is a string of characters that may include spaces. A, U, R, and V are separated from one another by exactly one space, and V runs to the end of the line.

The input ends with a line in which A is negative.

Output

For each input line, determine the percentage of the recommended daily requirement provided for that vitamin/mineral. If that percentage is at least 1%, print a line of the form:

V A U P%

where V, A, and U are the values from the input and P is the percentage of the minimum daily requirement represented by the amount A.

V is left-justified. A is printed with 1 digit after the decimal point, and P is printed with no digits after the decimal point (rounded to the nearest integer). V, A, U, and P are separated by a single space each.

After the last such line, print the line:

Provides no significant amount of:

followed by the names of all vitamins/minerals that provide less than 1% of the minimum daily requirement, one name per line, in the order they appeared in the input.

Examples3

  1. Example 1

    Input
    3500.0 iu 5000.0 Vitamin A
    60.0 mg 60.0 Vitamin C
    0.15 g 25.0 Fiber
    109. mg 990. Phosphorus
    0.0 mg 1000.0 Calcium
    25.0 mg 20.0 Niacin
    -1.0 x 0.0 x
    
    Expected output
    Vitamin A 3500.0 iu 70%
    Vitamin C 60.0 mg 100%
    Phosphorus 109.0 mg 11%
    Niacin 25.0 mg 125%
    Provides no significant amount of:
    Fiber
    Calcium
    
  2. Example 2

    Input
    100.0 mg 100.0 Iron
    50.0 mg 25.0 Zinc
    -1 x 0 x
    
    Expected output
    Iron 100.0 mg 100%
    Zinc 50.0 mg 200%
    Provides no significant amount of:
    
  3. Example 3

    Input
    0.5 mg 100.0 Sodium
    0.1 g 50.0 Potassium
    -1 x 0 x
    
    Expected output
    Provides no significant amount of:
    Sodium
    Potassium