Under construction

Still being built. Things may change

Ecology

Time limit1sMemory limit256 MB

Summary
Count how many times each tree species line appears, then print each species in lexicographic order with its share of the total, rounded to four decimals.
Level

Easy3 of 10

Topics
Hash map, String, Sorting
Solved
No attempts yet

Problem

In ecology, measuring the distribution of trees is important. Given a list of trees found across the United States, write a program that computes what percentage of all the trees each species accounts for.

Input

The input consists of several lines, with one tree species name per line. No species name is longer than 30 characters. There are at most 10,000 distinct species and at most 1,000,000 trees. A species name may contain spaces, so treat each entire line as a single species name.

Output

Print the name of every species that appears in the input in alphabetical (lexicographic) order. After each name, print the percentage of the total number of trees that the species represents, rounded to four decimal places. The percentage is computed as (number of trees of that species) × 100 ÷ (total number of trees), and the name and value are separated by a single space.

Hint

The input may contain only uppercase and lowercase English letters, space characters, digits, and special characters.

Examples2

  1. Example 1

    Input
    Red Alder
    Ash
    Aspen
    Basswood
    Ash
    Beech
    Yellow Birch
    Ash
    Cherry
    Cottonwood
    Ash
    Cypress
    Red Elm
    Gum
    Hackberry
    White Oak
    Hickory
    Pecan
    Hard Maple
    White Oak
    Soft Maple
    Red Oak
    Red Oak
    White Oak
    Poplan
    Sassafras
    Sycamore
    Black Walnut
    Willow
    
    Expected output
    Ash 13.7931
    Aspen 3.4483
    Basswood 3.4483
    Beech 3.4483
    Black Walnut 3.4483
    Cherry 3.4483
    Cottonwood 3.4483
    Cypress 3.4483
    Gum 3.4483
    Hackberry 3.4483
    Hard Maple 3.4483
    Hickory 3.4483
    Pecan 3.4483
    Poplan 3.4483
    Red Alder 3.4483
    Red Elm 3.4483
    Red Oak 6.8966
    Sassafras 3.4483
    Soft Maple 3.4483
    Sycamore 3.4483
    White Oak 10.3448
    Willow 3.4483
    Yellow Birch 3.4483
    
  2. Example 2

    Input
    Oak
    
    Expected output
    Oak 100.0000