poj 2418 Hardwood Species

POJ.rar_poj java_poj1048 POJ1048,加强版的约瑟夫问题 难度中等 立即下载
Hardwood Species
Time Limit: 10000MS Memory Limit: 65536K
Total Submissions: 25236 Accepted: 9707

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



这道题用map这种stl 真的很简单,感觉处理这种字符串出现频率的题目用map太方便了。。。

注意poj输出double型要用%f输出



#include<iostream>
#include<map>
#include<cstring>
#include<cstdio>
using namespace std;
int main(){
	map<string,double > m;
	string a;
	long long int js=0;
	while(getline(cin,a))
	{
		js++;
		m[a]++;
	}
	map<string,double > ::iterator zz;
	for(zz=m.begin();zz!=m.end();zz++)
	{
		cout<<zz->first<<" ";
		printf("%.4f\n",zz->second*100/js);
	}
	return 0;
}


在 Dify 平台部署一个 知识库问答(KBQA) 工作流 加强检索约束,Prompt 加限制(“仅基于知识库回答”):启用缓存,使用轻量级 LLM(如 Mistral-7B)(OpenAI Embedding、M3E、BGE等)(支持 PDF/TXT/Markdown/Word)(GPU/CPU 资源,用于向量数据库和模型推理)企业内部文档(PDF/Word/Excel)网页爬取数据(Markdown/HTML)分块大小(太小→信息碎片化,太大→噪声多)相似度阈值(太高→漏检,太低→噪声多)(是否返回正确文档)结构化数据(数据库/API) 阅读详情

相关推荐

factory机制-重载(一)

这里写自定义目录标题1.SystemVerilog对重载的支持2.对约束的重载3.factory 机制式的重载4.重载的方式和种类5.factory机制的调试 1.SystemVerilog对重载的支持 SystemVerilog是一种面向对象的语言。面向对象语言都有一大特征:重载。当在父类中定义一个函数/任务时,如果将其设置为virtual类型,那么就可以在子类中重载这个函数或任务。 重载的最大优势是使得一个子类的指针以父类的类型传递时,其表现的行为依然是子类的行为。 2.对约束的重载 在测试一个DUT时

sinat_41774721的博客 2963

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

Zemax光机热集成分析:从FEA数据导入到光学性能评估实战

在精密光学系统设计中,环境温度变化和机械应力是导致像质恶化的关键因素,这涉及到光、机、热多物理场的耦合分析。其核心原理在于,通过有限元分析(FEA)软件(如ANSYS)模拟热与力学载荷下的结构变形和温度分布,并将这些物理场数据精准映射到光学设计软件(如Zemax)中,以评估其对调制传递函数(MTF)、点列图等核心光学指标的影响。这项技术的工程价值在于,它使设计从静态的理想模型跃升至动态的工程现实,能够在设计阶段就预测并补偿环境扰动,从而显著提升光学系统在航空航天、车载镜头、高功率激光等严苛工况下的可靠性与稳

weixin_30565327的博客 365

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

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

代码改变世界 859

Brainstorm简单分析近红外数据(fNIRS)(一)

Brainstorm分析fNIRS数据

weixin_43604817的博客 1358

Altium Designer 17 PCB设计入门教程:从原理图到布线全流程

对于刚接触电子设计的工程师而言,PCB设计是一项基础且关键的工程技能。Altium Designer作为业界使用广泛的EDA工具,其17版本以成熟稳定的流程和大量现成教程资源,成为新手入门的高性价比选择。理解从原理图绘制、封装分配、到PCB布局布线的完整技术链路,是掌握硬件设计核心逻辑的必经之路。通过编译检查与DRC规则验证,设计者可在打样前规避开路、短路等常见电气错误,提升产品一次成功率。本文围绕AD17环境下的工程创建、初始偏好设置、常见报错排查及效率技巧展开,结合实际操作经验,帮助学习者快速建立一套可

weixin_42522669的博客 185

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 514

嵌入式开发中Tab与空格混用的危害与统一规范实践

在软件工程中,代码格式一致性是保障可读性与团队协作效率的基础。从原理上看,制表符(Tab)与空格(Space)在存储与显示机制上存在本质差异:Tab是控制字符,其显示宽度取决于编辑器设置;空格则是固定宽度的字符。这种差异导致混用时会引发代码对齐错乱、版本控制冲突及跨平台兼容性问题,严重影响工程的可维护性。尤其在嵌入式开发领域,资源受限环境与高可靠性要求使得统一的编码规范更为关键。通过配置编辑器、集成clang-format等自动化工具,可以强制实现缩进风格的一致性,从而提升代码质量与团队协作效率。本文聚焦于

weixin_42545636的博客 282

poj2418 Hardwood Species

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

ddmike2015的博客 427

【BUG已解决】ImportError: cannot import name ‘OpenAI‘ from ‘openai‘ 解决方案

的核心是版本不匹配用确认当前版本如果是 0.x 版本 →升级到 1.x升级后代码语法要同步改为团队协作项目务必在中锁定版本号,避免"我这能跑,你那不能跑"的问题对接国产模型时,只需替换base_url参数,SDK 调用方式完全一致。

一键难忘的博客 1万+

全面解析量化价值投资多因子模型的原理

明明知道“买便宜的好公司”是价值投资的核心,但面对3000+只A股,如何快速筛选出“便宜又好”的标的?主观判断总被情绪干扰——明明PE很低的股票,买了却不涨;或者因为“感觉”错过牛股?想规模化投资,但手动分析100只股票就要花一周,根本无法覆盖全市场?量化价值投资的多因子模型,正是解决这些问题的钥匙。它将价值投资的核心逻辑(“便宜”“好公司”)转化为可量化的因子,用数学模型替代主观判断,实现系统化筛选、可回测验证、规模化复制的投资决策。为什么多因子模型能有效预测股票收益?

AI天才研究院 1065

[字典树] poj 2418 Hardwood Species

题目链接: http://poj.org/problem?id=2418 Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 17511   Accepted: 6949 Description ...

weixin_33681778的博客 116

AI + 药物临床试验研发赛道

研究日期:2026-07-09 | 研究主题:AI + 药物临床试验研发赛道 | 聚焦岗位:Agent 平台架构师 / AI 工程架构师。

AI天才研究院 153

POJ2418 Hardwood Species

POJ2418 筱柒Littleseven QQ:3534947775 题目链接 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #define MAXN 300030 using namespace std; #define long l...

筱柒LittleSeven 209

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

POJ2418-Hardwood Species

【题目来源】http://poj.org/problem?id=2418 【题目思路】二叉搜索树 【解题感想】题目就是让你统计各种树木占总量的比例,但数据量非常大。本来想用STL的map的,但是听说会超时,还是没有用,自己写了一个BST。这是我第一次写BST,开始时候完全照pascal语言写的模板抄,但是实际实现时候在指针传递的时候发现一些问题,于是放弃了用指针传来传去的函数模板。不过我还

海能就下众水归,学问笃实生光辉 795

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

POJ 2418 Hardwood Species

题目大意: BST: 注释代码: 无注释代码: AVL: 注释代码: 无注释代码: 单词解释: hardwood:n, 阔叶树,硬木 hardwoods:n, 阔叶林

源代码 840

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

POJ 2418 Hardwood Species

Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 14326   Accepted: 5814 Description Hardwoods are the botanical group of trees that have broad

ACM2272902662的专栏 1399

poj-2418 Hardwood Species

题目数据很长就不放描述了。    题意:美国有各种各样不同的树木,你需要输入树木的名字,并且最后统计出每种树木所占的比例,并按字典序输出。 思路:字典树存储树的名字,统计每种树木的数量。除以输入数据的数量得到比例,最后输出即可,本题没有什么很难的算法,读懂题意就可以AC。 #include #include #include #include #include using

心の コード 891

poj 2418 Hardwood Species

题目链接:点击打开链接 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(

Vision 526

POJ 2418 Hardwood Species 【STL】

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 hu

u013180220的专栏 504

poj 2418Hardwood Species

题意是将输入的字符串按字典序输出,并且输出它出现的次数的百分比。 典型的字典树问题,建树并记录出现的次数就OK了啊、注意输入以Ctrl+Z退出、、 Hardwood Species Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 15937   Accepted: 6381

I am a slow walker, but I never walk backwards! 2277
上一篇: poj 2402 Palindrome Numbers
下一篇: codeforces 837B Flag of Berland
threeh20
博客等级 码龄9年 64粉丝 422原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值