poj 2418 map的简单使用

POJ.rar_poj java_poj1048 POJ1048,加强版的约瑟夫问题 难度中等 立即下载

Hardwood Species
Time Limit: 10000MS Memory Limit: 65536K
Total Submissions: 24642 Accepted: 9521

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

用map处理输入的字符串,记录下字符串出现的次数,由于map会将数据排好序,直接遍历输出就好了。

#include<iostream>
#include<map>
#include<iomanip>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
    map<string,float>m;///如果写成map<string,int>则会出错,这里也可以写成double
    string str;
    int cnt=0;
    while(getline(cin,str))
    {
        m[str]++;
        cnt++;
    }
    map<string,float>::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        cout<<fixed<<setprecision(4)<<it->first<<" "<<100.0*(it->second/cnt)<<endl;
    }
}


Windows加域迁移避坑指南:Profwiz工具实战中的5个常见问题与解决方案 本文详细解析了使用Profwiz工具进行Windows加域迁移时的5个常见问题及解决方案,包括临时配置文件生成、密码策略冲突、SID冲突等。通过实战案例和优化技巧,帮助IT运维团队高效完成账户配置文件迁移,确保Active Directory环境下的数据完整性和权限无缝衔接。 阅读详情

相关推荐

影刀RPA:轻松搞定Excel表格自动化操作

影刀RPA是一款功能强大的自动化工具,通过模拟人类操作实现各种重复性任务的自动化。零代码操作:通过拖拽式流程设计器,无需编程基础即可快速上手。功能丰富:提供丰富的组件库,涵盖文件操作、数据处理等多种功能。高效稳定:支持多任务并行,确保任务的高效执行和稳定性。支持Python语法:内置数据表格,支持Python语法,对新手友好,同时具备循环功能。通过影刀RPA,您可以轻松实现Excel表格的拆分、列数据合并和归档工作的自动化。这不仅节省了手动操作的时间,还能确保数据处理的高效和准确,提升工作效率和管理水平。

watwrmoon的博客 2560

POJ2418 Hardwood Species STL

水题 直接使用MAP即可 Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 14927   Accepted: 6003 Description Hardwoods are the botanical group of trees

684

Kubernetes多网卡环境下Calico网络配置避坑指南:如何精准指定业务网卡

本文针对Kubernetes多网卡环境下Calico网络配置的常见痛点,提供了精准指定业务网卡的实战指南。通过深入分析Calico的IP自动检测机制,详细解读并对比了五种IP_AUTODETECTION_METHOD配置方法(如interface、cidr、can-reach等),帮助运维人员从根源上解决网络分区和Pod通信失败问题,确保生产集群网络的稳定与可靠。

weixin_28835551的博客 730

【POJ No. 2418】硬木种类 Hardwood Species

【POJ No. 2418】硬木种类 Hardwood Species

代码改变世界 857

logisim计组实验八 乘法器

原理:点这里 有问题欢迎留言哦~ 文章目录五位阵列乘法器电路图时间延迟分析六位补码阵列乘法器五位无符号乘法流水线原理图电路图原码一位乘法器原理图电路图补码一位乘法器 五位阵列乘法器 电路图 此处注意:全加器FA的cout端是进位端而非输出端 使用硬件控制比循环累加的速度快得多。 但是存在串行进位链 改进版: 时间延迟分析 T是计算相加数的一级门延迟 3n–>2n 性能差别在1.5倍 ...

treblez's blog 2万+

物理学建模及仿真平台Chrono安装

Chrono是一个基于物理学的建模和仿真基础设施,它是在C++中实现的独立于平台的开源设计。一个projectchrono库可以嵌入到一个软件项目中,例如在可变形地形上运行的轮式和履带式车辆、机器人、机械电子系统、顺应性机构和流体固体相互作用现象。系统可以由刚性和柔性/顺应性部件组成,并带有约束、电机和接触;部件可以具有三维形状,以便进行碰撞检测。然而安装还是出现了一些问题,所以在此总结。已经装好visual studio。

Already8888的博客 6501

poj_2418 Hardwood Species (字典序Trie树)

又是一道典型的Trie树应用题,有了Trie树的基本知识,写起来就非常容易了~~ 【题目描述】 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 tempera

Je vole 513

基于MATLAB的特征模式分解(FMD)算法详解

本文详细介绍了基于MATLAB的特征模式分解(FMD)算法实现。FMD是一种新型自适应信号分解方法,通过自适应FIR滤波器组和相关峭度优化目标,有效解决传统方法(如EMD、VMD)的模态混叠问题。文章系统阐述了FMD的算法原理、数学模型和实现步骤,包括自适应FIR滤波器设计、相关峭度优化和模态选择机制。与现有方法相比,FMD在旋转机械故障诊断中展现出更强的特征提取能力和噪声鲁棒性。MATLAB实现部分包含核心函数、参数优化和可视化工具,并通过轴承故障等案例验证了算法的有效性。

qq_42212808的博客 193

poj2418 Hardwood Species

题目意思:美国有很多种类的树,有硬木的,有软木的,现在输入一堆树,根据树名的字典序,从小到大输出树名及它占所有树种的比例 这题可以用很多方法解,目前只用了AVL搜索树这种方法,就是AVL搜索树的一个套用 提醒一句,貌似好多人用g++交就是错的,c++交就是对的 代码如下: #include #include #include #include #include #include using

ddmike2015的博客 427

8.26华为OD机试真题 新系统 - 字符串回文判 (Java/Py/C/C++/Js/Go)

8.26华为OD机试真题 新系统 - 字符串回文判 (Java/Py/C/C++/Js/Go)

算法大师! 1236

Android Framework 开发工程师职位深度解析与面试指南

摘要:博泰车联网科技(上海)股份有限公司招聘Android Framework开发工程师,负责车载系统的底层开发与优化。岗位要求5年以上经验,深入掌握Android Framework机制(WindowManager、PowerManager等模块),熟悉高通平台中间件架构及NDK/JNI开发,具备性能优化(启动时间、ANR处理)、OTA升级等能力。需熟练使用Android Studio、Git等工具,有车载开发经验者优先。工作内容包括Framework定制开发、问题排查及技术文档编写。

郑伟强dev的专栏 552

poj-2418 Hardwood Species(用map处理字符串)

题目链接 poj2418 题意 题意:美国有各种各样不同的树木,你需要输入树木的名字,并且最后统计出每种树木所占的比例,并按字典序输出。 代码 #include<iostream> #include<map> #include<string> #include<iomanip> #include<cstdio> using namespace std; int main() { //freopen("data.txt","r",stdin);

weixin_47750287的博客 177

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

poj 2418 字典树/map Hardwood Species

二叉搜索树 字典树

weixin_46266058的博客 353

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

POJ 2418 Hardwood Species(STL在map应用)

职务地址:POJ 2418 通过这个题查了大量资料。。知道了非常多曾经不知道的东西。。。。 在代码中凝视说明吧。 代码例如以下: #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;string&gt; #include &lt;cstring&gt; #include &lt;stdlib.h&gt; #i...

weixin_34080951的博客 86

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

poj 2418 简单map

c++过得,G++ 不知为啥过不了……&………… #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { mapM

风一样的自由,色彩斑斓的雨季 555

poj 2418 Hardwood Species (map)

题目:http://poj.org/problem?id=2418 在poj 上交题总是有各种错误,再次感叹各个编译器。 c++ AC代码,G++为超时,上代码: 1 #include<cstdio> 2 #include<string> 3 #include<map> 4 using namespace std; 5 ...

weixin_30800807的博客 97

POJ 2418 (简单map)

题意:输入字符串,按字典序输出字符串和它所占的百分比。 map是一个容器,存入数据的时候默认字典序存入,只是不经常用所以很难控制输入输出。 对于getline的解释:    istream&getline ( istream &is , string &str, char delim );里面分别是:输入方式,输入目标,停止标记,来源:http://blog.sina.com.cn/s/

Since_natural_ran 672

poj2418map或者字典树

题意:      给你一些串,然后求出每个串出现的概率。 思路:      简单题目,做法也很多,我用字典树做了下,然后又用map做了下,其实这个题目我感觉直接排序一遍之后线性输出应该是最简单最快的(这个没敲),就是只是排序的时间复杂度而已O(n*log(n)*len)字典序的排序时间复杂度记得*len. 字典树829MS #include #include #incl

天使也掉毛 555

POJ2418——Hardwood Species(map映射)

Hardwood Species DescriptionHardwoods 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 produc...

weixin_30835649的博客 152

POJ 2418 Hardwood Species(map)

第一次接触map~\(≧▽≦)/~

笨鸟 842

POJ 2418 Hardwood Species(STL中map的应用)

题目地址:POJ 2418 通过这个题查了大量资料。。知道了很多以前不知道的东西。。。。 在代码中注释说明吧。 代码如下: #include #include #include #include #include #include #include #include #include #include using namespace std; int main() {

scf0920 1384

poj 2418 Hardwood Species --- 再来复习遍map吧

题目是统计字符串出现的频率,应该是用二分排序树做的吧。 这里 8000多ms。。 输入输出纠结死我了。。。 再记一遍 输入: map mapStudent; 1、mapStudent.insert(pair(1, “student_one”)); 2、mapStudent.insert(map::value_type (2, “student_two”)); 3

Unknown 1152

POJ 2418 Hardwood Species(map的应用)

Hardwood Species Time Limit:10000MS Memory Limit:65536K Total Submissions:15216 Accepted:6125 Description Hardwoods are the botanical group of trees that...

MengDeMao1234的博客 254

POJ2418 UVA10226 ZOJ1899 Hardwood Species【map】

Hardwood Species Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 26828 Accepted: 10215 Description Hardwoods are the botanical group of trees that have broad leaves, produce a fruit or n...

海岛Blog 982

POJ 2418 Hardwood Species(map运用)

POJ 2418 Hardwood Species(map运用)

1593
上一篇: poj 1504 水题
下一篇: poj2909 哥德巴赫猜想
皮皮蟹01
博客等级 码龄10年 29粉丝 76原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值