Hardwood species
Time Limit: 10000MS |
|
Memory Limit: 65536K |
Total Submissions: 20811 |
|
Accepted: 8158 |
Description
Hardwoods is the botanical group of trees that has broad leaves, produce a fruit or nut, and generally go dormant in the Winter.
America ' s temperate climates produce forests with hundreds of hardwood species--trees that share certain biological char Acteristics. Although oak, maple and cherry All is types of hardwood trees, for example, they is different species. Together, all the hardwood species represent-percent of the trees in the "states".
On the other hand, softwoods, or conifers, from the Latin word meaning "cone-bearing," has needles. Widely available US softwoods include cedar, fir, hemlock, pine, redwood, spruce and cypress. In a home, the softwoods is used primarily as structural lumber such as 2x4s and 2x6s, with some limited decorative appli Cations.
Using Satellite imaging technology, the Department of Natural Resources have compiled an inventory of every tree standing O n a particular day. You is to compute the total fraction of the tree population represented by each species.
Input
Input to your program consists of a list of the species of the every tree observed by the satellite; One tree per line. No species name exceeds-characters. There is no more than species and no more than 1,000,000 trees.
Output
Print the name of each species represented in the population, in alphabetical order, followed by the percentage of the pop Ulation it represents, to 4 decimal places.
Sample Input
Red Alderashaspenbasswoodashbeechyellow birchashcherrycottonwoodashcypressred Elmgumhackberrywhite Oakhickorypecanhard maplewhite oaksoft maplered oakred oakwhite oakpoplansassafrassycamoreblack WalnutWillow
Sample Output
Ash 13.7931Aspen 3.4483Basswood 3.4483Beech 3.4483Black Walnut 3.4483Cherry 3.4483Cottonwood 3.4483Cypress 3.4483Gum 3.4483Hackberry 3.4483Hard Maple 3.4483Hickory 3.4483Pecan 3.4483Poplan 3.4483Red Alder 3.4483Red Elm 3.4483Red Oak 6.8966 Sassafras 3.4483Soft Maple 3.4483Sycamore 3.4483White Oak 10.3448Willow 3.4483Yellow Birch 3.4483
Hint
This problem have huge input, use scanf instead of CIN to avoid time limit exceeded.
Source
Waterloo Local 2002.01.26
Accode:
#include <map> #include <cstdio> #include <cstring> #include <string> #include <iostream> Using namespace Std;typedef map<string,int>record;string S;record h;int Main () { int n=0; while (Getline (cin,s)) { n++; h[s]++; } For (Record::iterator It=h.begin (); It!=h.end (); it++) { string name= (*it). First; int k= (*it). Second; printf ("%s%.4lf\n", Name.c_str (), double (k) *100/double (n)); } return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
POJ 2418 Hardwood species STL Real Province code AH