Hardwood Species

Time Limit: 10000MS Memory Limit: 65536K

Total Submissions: 20619 Accepted: 8083

Description

Hardwoods are the botanical group of trees that have 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 characteristics. Although oak, maple and cherry all are types of hardwood trees, for example, they are different species. Together, all the hardwood species represent 40 percent of the trees in the United States.

On the other hand, softwoods, or conifers, from the Latin word meaning “cone-bearing,” have needles. Widely available US softwoods include cedar, fir, hemlock, pine, redwood, spruce and cypress. In a home, the softwoods are used primarily as structural lumber such as 2x4s and 2x6s, with some limited decorative applications.

Using satellite imaging technology, the Department of Natural Resources has compiled an inventory of every tree standing on a particular day. You are 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 every tree observed by the satellite; one tree per line. No species name exceeds 30 characters. There are no more than 10,000 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 population it represents, to 4 decimal places.

Sample 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

Sample 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

Hint

This problem has huge input, use scanf instead of cin to avoid time limit exceeded.

Source

Waterloo Local 2002.01.26

题意:给你树的名字,统计每种树在所有树中所占的比例;

做法:题意中只说不超过30个字符,却没有说字符的范围,敲了字典树RE,果断的换二叉排序树

#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
#define eps 1e-9
#define LL long long
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define CRR fclose(stdin)
#define CWW fclose(stdout)
#define RR freopen("input.txt","r",stdin)
#pragma comment(linker, "/STACK:102400000")
#define WW freopen("output.txt","w",stdout) const int MAX = 300010; struct node
{
int num;
char str[35];
node *L;
node *R;
} Tree;
char s[35];
int sum;
node * Creat()
{
node *p;
p=new node;
p->num=1;
p->R=NULL;
p->L=NULL;
p->str[0]='\0';
return p;
}
void BuildSortTree(node *Root)
{
if(strcmp(Root->str,s)==0)
{
Root->num++;
return ;
}
if(strcmp(Root->str,s)>0)
{
if(Root->L==NULL)
{
Root->L=Creat();
strcpy(Root->L->str,s);
return ;
}
else
{
BuildSortTree(Root->L);
}
}
else
{
if(Root->R==NULL)
{
Root->R=Creat();
strcpy(Root->R->str,s);
return ;
}
else
{
BuildSortTree(Root->R);
}
} }
void DFS_Tree(node *p)//中序遍历
{
if(p==NULL)
{
return;
}
DFS_Tree(p->L);
printf("%s %.4f\n",p->str,p->num*100.0/sum);
DFS_Tree(p->R);
}
int main()
{
Tree.num=1;
Tree.R=NULL;
Tree.L=NULL;
sum=0;
while(gets(s))
{
if(sum==0)
{
strcpy(Tree.str,s);
}
else
{
BuildSortTree(&Tree);
}
sum++;
}
DFS_Tree(&Tree);
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Hardwood Species 分类: POJ 树 2015-08-05 16:24 2人阅读 评论(0) 收藏的更多相关文章

  1. Mahout快速入门教程 分类: B10_计算机基础 2015-03-07 16:20 508人阅读 评论(0) 收藏

    Mahout 是一个很强大的数据挖掘工具,是一个分布式机器学习算法的集合,包括:被称为Taste的分布式协同过滤的实现.分类.聚类等.Mahout最大的优点就是基于hadoop实现,把很多以前运行于单 ...

  2. Hiking 分类: 比赛 HDU 函数 2015-08-09 21:24 3人阅读 评论(0) 收藏

    Hiking Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Subm ...

  3. hdu 1503, LCS variants, find a LCS, not just the length, backtrack to find LCS, no extra markup 分类: hdoj 2015-07-18 16:24 139人阅读 评论(0) 收藏

    a typical variant of LCS algo. the key point here is, the dp[][] array contains enough message to de ...

  4. 利用OpenMP实现埃拉托斯特尼(Eratosthenes)素数筛法并行化 分类: 算法与数据结构 2015-05-09 12:24 157人阅读 评论(0) 收藏

    1.算法简介 1.1筛法起源 筛法是一种简单检定素数的算法.据说是古希腊的埃拉托斯特尼(Eratosthenes,约公元前274-194年)发明的,又称埃拉托斯特尼筛法(sieve of Eratos ...

  5. Improving the GPA 分类: 贪心 HDU 比赛 2015-08-08 16:12 11人阅读 评论(0) 收藏

    Improving the GPA Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...

  6. Task schedule 分类: 比赛 HDU 查找 2015-08-08 16:00 2人阅读 评论(0) 收藏

    Task schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 菜鸟学习-C语言函数参数传递详解-结构体与数组 分类: C/C++ Nginx 2015-07-14 10:24 89人阅读 评论(0) 收藏

    C语言中结构体作为函数参数,有两种方式:传值和传址. 1.传值时结构体参数会被拷贝一份,在函数体内修改结构体参数成员的值实际上是修改调用参数的一个临时拷贝的成员的值,这不会影响到调用参数.在这种情况下 ...

  8. android开发之broadcast学习笔记 分类: android 学习笔记 2015-07-19 16:33 32人阅读 评论(0) 收藏

    android中的广播用的太多了,今天稍微总结一下. 按注册方式分为两种: 1.静态注册广播: 静态注册广播就是在androidManifest.xml文件中注册广播,假设我们要实现这样一个效果,在一 ...

  9. AndroidManifest.xml中的application中的name属性 分类: android 学习笔记 2015-07-17 16:51 116人阅读 评论(0) 收藏

    被这个不起眼的属性折磨了一天,终于解决了. 由于项目需要,要合并两个android应用,于是拷代码,拷布局文件,拷values,所有的都搞定之后程序还是频频崩溃,一直没有找到原因,学android时间 ...

随机推荐

  1. mongodb概念

    一.mongodb与关系型数据库的一些概念上的改变 sql术语 mongodb术语 说明 database database 数据库 table collection 表/集合 row documen ...

  2. Swift游戏实战-跑酷熊猫 10 视差滚动背景

    原理 实现 勘误 “实现”的视频中有个错误,如下 背景移动时有个错误,看红色部分,近景归位时,第二张图片的下标是1 if arrBG[0].position.x + arrBG[0].frame.wi ...

  3. p++ ++p

    1.P++是先使用这个变量,使用完了再加1,你的例子就是,先输出,再加一++P是先加一,在使用变量 eg: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 ...

  4. JAVA-环境部分

    JAVA环境 1.jdk 1.从Oracle网站下载安装包(32位.64位) 2.安装目录不用中文或空格 3.配置环境变量 1作用:提供jdk存放位置信息 2系统环境变量 1增加-JAVA_HOME= ...

  5. 转:Apache POI Tutorial

    Welcome to Apache POI Tutorial. Sometimes we need to read data from Microsoft Excel Files or we need ...

  6. 暴力枚举-数长方形(hdu5258)

    数长方形 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submis ...

  7. C# Winform 水波纹效果

    //添加自定义控件 using System; using System.Collections.Generic; using System.ComponentModel; using System. ...

  8. 夺命雷公狗jquery---4内容选择器

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...

  9. 【转】转换到 COFF 期间失败: 文件无效或损坏

    不知怎么本来编译好好的VS2010环境,忽然出现“转换到 COFF 期间失败: 文件无效或损坏”的链接错误.花了好多天,试了好多方法,最终解决了这个问题.   现在罗列一下这几种解决方案:   方案1 ...

  10. windows下nginx和php环境的配置

    至于php的配置,与之前博文中使用apache服务器时一样. 对于nginx的配置,来看看如何修改配置文件: #user nobody; worker_processes ; #error_log l ...