POJ 2418-Hardwood Species(map)
| Time Limit: 10000MS | Memory Limit: 65536K | |
| Total Submissions: 18770 | Accepted: 7405 |
Description
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
Output
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
题意:给一堆单词(有反复),然后按字典序打印出全部单词(无反复) 而且输出每一个单词占总单词数的百分率。
值得注意的是G++提交要用%f 而C++用%lf
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <queue>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
string x;
long long cnt=0;
map <string,int> m;
while(getline(cin,x)){
cnt++;
m[x]++; }
map <string,int>::iterator it=m.begin();
while(it!=m.end())
{
printf("%s ",it->first.c_str());
printf("%.4lf\n",it->second*100.0/cnt);
++it;
}
return 0;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
POJ 2418-Hardwood Species(map)的更多相关文章
- POJ - 2418 Hardwood Species(map,trie,BST)
1.输入若干行树名,输入结束后,按字典序输出树名及其所占百分比. 2.多种方法:map,trie,BST 3. map: #include<iostream> #include<st ...
- Hardwood Species(map)
http://poj.org/problem?id=2418 题意:给定一系列字符串,要求按字典序升序输出每个串,并输出每个串出现的百分比. 用map做的,交c++A了,G++ WA..so sad. ...
- [字典树] poj 2418 Hardwood Species
题目链接: id=2418">http://poj.org/problem?id=2418 Hardwood Species Time Limit: 10000MS Memory ...
- POJ 2418 Hardwood Species(STL在map应用)
职务地址:id=2418">POJ 2418 通过这个题查了大量资料..知道了非常多曾经不知道的东西. . .. 在代码中凝视说明吧. 代码例如以下: #include <ios ...
- [ACM] POJ 2418 Hardwood Species (Trie树或map)
Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 17986 Accepted: 713 ...
- POJ 2418 Hardwood Species
Hardwood Species Time Limit: 10000MS Memory Limit ...
- Hardwood Species(水)
Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u SubmitStatus Descrip ...
- poj 2418 Hardwood Species (map)
题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器. c++ AC代码,G++为超时,上代码: #include<cstdio ...
- POJ 2418 Hardwood Species (哈希,%f 和 %lf)
我的错因: 本来改用%f输出,我用了%lf,结果编译器直接判定为错误(一部分编译器认为lf是没有错的).当时我还以为是hash出错了.. 方法不止一种: 方法 时间 空间 Hash 891ms 5 ...
随机推荐
- 使用mingw制作dll文件
使用mingw制作dll文件 安装mingw 准备math.c文件 //math.c #include<stdio.h> int add(int a,int b){ return a+b; ...
- 为SSO 5.5恢复忘记的administrator@vsphere.local密码
转自:http://blog.itpub.net/27042095/viewspace-1179938/ 1. cd \Program Files\VMware\Infrastructure\VMwa ...
- C# 数据通信
json asmxwcfwebRequestwebClient 串口 socket
- struts2_7_Action类中方法的动态调用
(一)直接调用方法(不推荐使用) 1)Action类: private String savePath; public String getSavePath() { return savePath; ...
- [Angular] Stagger animation v4.3.3
For example, when we open a form, we want to see all the inputs fields comes into one by one. Code f ...
- Linux平台Makefile文件的编写基础篇
目的: 基本掌握了 make 的用法,能在Linux系统上编程. 环境: Linux系统,或者有一台Linux服务器,通过终端连接.一句话:有Linux编译环境. 准备: ...
- 3、Unicode\UTF-8\GBK 区别和联系
字符编码:Unicode和UTF-8之间的关系 可以参考下面blog:https://blog.csdn.net/xiaolei1021/article/details/52093706/ 这篇文章写 ...
- RabbitMQ安全相关的网络资源介绍
无法用guest远程訪问RabbitMQ的的解决方式 Can't access RabbitMQ web management interface after fresh install http:/ ...
- 结合Wireshark捕获分组深入理解TCP/IP协议栈之HTTP协议
摘要: 本文简单介绍了Web应用层协议理论知识,详细讲述了HTTP请求报文和响应报文各个字段含义,并从Wireshark俘获分组中选取HTTP相关报文进行分析. 一.概述 Web的应用 ...
- 【3005】拦截导弹问题(noip1999)
Time Limit: 3 second Memory Limit: 2 MB 某国为了防御帝国的导弹袭击,开发出一种导弹拦截系统,但是这种拦截系统有一个缺陷:虽然他的第一发炮弹能达到任意的高度,但是 ...