Hardwood Species 分类: POJ ...

本博客提供了一种方法来使用卫星成像技术统计美国森林中每种硬木树在整体树群中所占的比例,包括输入格式、输出要求和示例代码。

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;
}

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

转载于:https://www.cnblogs.com/juechen/p/4721928.html

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Premium Materials Gallery</title> <style> /* 容器样式 */ .luxemg-container { max-width: 80%; margin: 0 auto; padding: 40px 20px; position: relative; } /* 标题区域 */ .luxemg-header { text-align: center; margin-bottom: 50px; padding-bottom: 20px; border-bottom: 1px solid #e0e0e0; } .luxemg-title { font-weight: 300; letter-spacing: 2px; color: #333; margin: 0 0 10px 0; font-size: 28px; } .luxemg-subtitle { color: #7a7a7a; max-width: 600px; margin: 0 auto; line-height: 1.6; } /* 网格布局 */ .luxemg-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 30px; } /* 卡片样式 */ .luxemg-card { background: white; border-radius: 8px; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.05); transition: transform 0.3s ease, box-shadow 0.3s ease; position: relative; display: flex; flex-direction: column; height: 100%; } .luxemg-card:hover { transform: translateY(-8px); box-shadow: 0 12px 25px rgba(0,0,0,0.08); } .luxemg-card-image { height: 240px; overflow: hidden; background: #f8f8f8; } .luxemg-card-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s ease; } .luxemg-card:hover .luxemg-card-img { transform: scale(1.05); } .luxemg-card-content { padding: 25px; flex-grow: 1; display: flex; flex-direction: column; } .luxemg-card-title { font-weight: 400; margin: 0 0 15px 0; font-size: 22px; letter-spacing: 1px; color: #222; } .luxemg-card-desc { color: #666; line-height: 1.7; margin: 0 0 20px 0; font-size: 16px; flex-grow: 1; } /* 详情按钮样式 */ .luxemg-detail-btn { display: inline-block; padding: 10px 20px; background: #000; color: white; border: 2px solid #000; border-radius: 4px; cursor: pointer; font-weight: 500; letter-spacing: 1px; text-transform: uppercase; font-size: 14px; transition: all 0.3s ease; align-self: flex-start; } .luxemg-detail-btn:hover { background: white !important; color: black !important; } /* 模态框样式 */ #luxemg-modal-container { position: fixed; top: 0; left: 10%; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: none; z-index: 10000; opacity: 0; transition: opacity 0.3s ease; } .luxemg-modal-wrapper { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 20px; box-sizing: border-box; } .luxemg-modal-content { background: white; width: 100%; max-width: 900px; max-height: 90vh; border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 20px 40px rgba(0,0,0,0.3); transform: scale(0.95); transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.3s ease; opacity: 0; } .luxemg-modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px; border-bottom: 1px solid #eee; } .luxemg-modal-title { margin: 0; font-size: 24px; font-weight: 400; color: #333; } .luxemg-close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: #888; transition: color 0.3s; } .luxemg-close-btn:hover { color: #333; } .luxemg-modal-body { display: flex; overflow: auto; flex-grow: 1; padding: 0; } .luxemg-modal-image-container { width: 50%; min-width: 300px; background: #f8f8f8; display: flex; align-items: center; justify-content: center; padding: 30px; } .luxemg-modal-img { max-width: 100%; max-height: 400px; object-fit: contain; } .luxemg-modal-description { width: 50%; padding: 30px; overflow-y: auto; } .luxemg-modal-desc { line-height: 1.8; color: #555; } .luxemg-specs-table { width: 100%; border-collapse: collapse; margin-top: 25px; font-size: 15px; } .luxemg-specs-table th { padding: 10px; text-align: left; border-bottom: 1px solid #eee; background: #f5f5f5; } .luxemg-specs-table td { padding: 10px; border-bottom: 1px solid #eee; } /* 响应式设计 */ @media (max-width: 1024px) { .luxemg-grid { grid-template-columns: repeat(2, 1fr); } } @media (max-width: 768px) { .luxemg-container { padding: 30px 15px; } .luxemg-grid { grid-template-columns: 1fr; gap: 25px; } .luxemg-card { max-width: 500px; margin: 0 auto; } .luxemg-modal-body { flex-direction: column; } .luxemg-modal-image-container, .luxemg-modal-description { width: 100% !important; } .luxemg-modal-image-container { height: 300px; min-height: auto; } } @media (max-width: 480px) { .luxemg-title { font-size: 24px; } .luxemg-card-title { font-size: 20px; } .luxemg-card-desc { font-size: 15px; } } @media (max-height: 700px) { .luxemg-modal-content { max-height: 85vh; } } </style> </head> <body> <div class="luxemg-container"> <!-- 材料展示网格 --> <div class="luxemg-grid"> <!-- 材料项 1 --> <div class="luxemg-card"> <div class="luxemg-card-image"> <img src="https://www.fetchingpack.com/wp-content/uploads/2025/06/ChatGPT-Image-2025年6月18日-16_45_42_compressed.png" alt="double-sided coated paper" class="luxemg-card-img"> </div> <div class="luxemg-card-content"> <h3 class="luxemg-card-title">double-sided coated paper</h3> <button class="luxemg-detail-btn" data-luxemg-modal="modal1">VIEW MORE</button> </div> </div> <!-- 材料项 2 --> <div class="luxemg-card"> <div class="luxemg-card-image"> <img src="https://via.placeholder.com/600x400/e8极8e8/999999?text=Oak+Hardwood" alt="Oak Hardwood" class="luxemg-card-img"> </div> <div class="luxemg-card-content"> <h3 class="luxemg-card-title">Oak Hardwood</h3> <p class="luxemg-card-desc">European white oak with natural grain patterns...</p> <button class="luxemg-detail-btn" data-luxemg-modal="modal2">VIEW MORE</button> </div> </div> <!-- 材料项 3 --> <div class="luxemg-card"> <div class="luxemg-card-image"> <img src="https://via.placeholder.com/600x400/e8e8e8/999999?text=Brushed+Brass" alt="Brushed Brass" class="luxemg-card-img"> </div> <div class="luxemg-card-content"> <h3 class="luxemg-card-title">Brushed Brass</h3> <p class="luxemg-card-desc">Hand-finished brass with subtle texture...</p> <button class="luxemg-detail-btn" data-luxemg-modal="modal3">VIEW MORE</button> </div> </div> <!-- 材料项 4 --> <div class="luxemg-card"> <div class="luxemg-card-image"> <img src="https://via.placeholder.com/600x400/e8e8e8/999999?text=Ceramic+Tiles" alt="Ceramic Tiles" class="luxemg-card-img"> </div> <div class="luxemg-card-content"> <h3 class="luxemg-card-title">Ceramic Tiles</h3> <p class="luxemg-card-desc">High-gloss ceramic tiles with exceptional durability...</p> <button class="luxemg-detail-btn" data-luxemg-modal="modal4">VIEW MORE</button> </div> </div> </div> </div> <!-- 模态框容器 --> <div id="luxemg-modal-container" class="luxemg-modal-container"> <div class="luxemg-modal-wrapper"> <div class="luxemg-modal-content"> <div class="luxemg-modal-header"> <h3 id="luxemg-modal-title" class="luxemg-modal-title">Material Details</h3> <button id="luxemg-close-modal" class="luxemg-close-btn">×</button> </div> <div class="luxemg-modal-body"> <div class="luxemg-modal-image-container"> <img id="luxemg-modal-image" class="luxemg-modal-img" src="" alt="Material"> </div> <div class="luxemg-modal-description"> <div id="luxemg-modal-description" class="luxemg-modal-desc"></div> <table class="luxemg-specs-table"> <thead> <tr> <th>Property</th> <th>Value</th> </tr> </thead> <tbody id="luxemg-modal-specs" class="luxemg-specs-body"></tbody> </table> </div> </div> </div> </div> </div> <script> // 使用IIFE创建私有作用域避免全局污染 (function() { // 材料详情数据 - 使用唯一前缀 const luxemgMaterialDetails = { modal1: { title: "Italian Marble", image: "https://via.placeholder.com/800x600/e8e8e8/999999?text=Italian+Marble+Detail", description: "<p>Premium Carrara marble quarried directly from the Apuan Alps in Tuscany, Italy. This exquisite natural stone features distinctive soft gray veining on a white or blue-gray background, creating timeless elegance.</p><p>Each slab is carefully selected for its unique pattern and quality, ensuring minimal imperfections. Ideal for high-end countertops, flooring, and feature walls. The marble undergoes a specialized polishing process to enhance its natural luster and durability.</p>", specs: [ { property: "Origin", value: "Carrara, Italy" }, { property: "Hardness", value: "3-4 on Mohs scale" }, { property: "Thickness", value: "2cm, 3cm" }, { property: "Finish", value: "Polished, Honed" }, { property: "Maintenance", value: "Sealing recommended" } ] }, modal2: { title: "Oak Hardwood", image: "https://via.placeholder.com/800x600/e8e8e8/999999?text=Oak+Hardwood+Detail", description: "<p>European white oak (Quercus robur) sourced from sustainably managed forests. This premium hardwood features a straight grain with occasional swirls and burls, offering a warm, natural appearance.</p><p>The wood undergoes a meticulous kiln-drying process to achieve optimal moisture content (8-10%), ensuring dimensional stability. Available in various grades from rustic to select, suitable for flooring, furniture, and architectural elements. The natural tannin content provides inherent resistance to insects and decay.</p>", specs: [ { property: "Species", value: "Quercus robur" }, { property: "Janka Hardness", value: "1360 lbf" }, { property: "Density", value: "720 kg/m³" }, { property: "Moisture Content", value: "8-10%" }, { property: "Sustainability", value: "FSC Certified" } ] }, modal3: { title: "Brushed Brass", image: "https://via.placeholder.com/800x600/e8e8e8/999999?text=Brushed+Brass+Detail", description: "<p>Hand-finished brass with a distinctive brushed texture that diffuses light and minimizes fingerprints. This premium alloy contains 85% copper and 15% zinc, offering a warm golden hue that develops a rich patina over time.</p><p>The brushing process creates subtle linear patterns that enhance depth and character. A protective lacquer coating is applied to preserve the finish while allowing for natural aging. Ideal for hardware, fixtures, and decorative accents in both contemporary and traditional settings.</p>", specs: [ { property: "Composition", value: "85% Copper, 15% Zinc" }, { property: "Finish", value: "Satin Brushed" }, { property: "Thickness", value: "1.2mm - 3mm" }, { property: "Protection", value: "Clear Lacquer Coated" }, { property: "Patina Development", value: "Slow, even" } ] }, modal4: { title: "Ceramic Tiles", image: "https://via.placeholder.com/800x600/e8e8e8/999999?text=Ceramic+Tiles+Detail", description: "<p>High-gloss ceramic tiles manufactured using advanced digital printing technology that replicates natural stone with remarkable fidelity. The durable glaze is formulated for exceptional scratch and stain resistance.</p><p>These tiles feature a through-body color composition, meaning any chips or scratches are less noticeable. The rectified edges allow for minimal grout lines (as small as 1.5mm), creating a seamless appearance. Suitable for both walls and floors in high-traffic areas.</p>", specs: [ { property: "Material", value: "Porcelain Ceramic" }, { property: "PEI Rating", value: "IV (Heavy Traffic)" }, { property: "Water Absorption", value: "<0.5%" }, { property: "Slip Resistance", value: "R10 (Dry)" }, { property: "Sizes", value: "60x60cm, 30x60cm" } ] } }; // DOM元素引用 const luxemgModalContainer = document.getElementById('luxemg-modal-container'); const luxemgModalTitle = document.getElementById('luxemg-modal-title'); const luxemgModalImage = document.getElementById('luxemg-modal-image'); const luxemgModalDescription = document.getElementById('luxemg-modal-description'); const luxemgModalSpecs = document.getElementById('luxemg-modal-specs'); const luxemgCloseModal = document.getElementById('luxemg-close-modal'); // 打开模态框函数 function openLuxemgModal(modalId) { const material = luxemgMaterialDetails[modalId]; const modalContent = luxemgModalContainer.querySelector('.luxemg-modal-content'); if (!material) { console.error("Material details not found for:", modalId); return; } // 填充模态框内容 luxemgModalTitle.textContent = material.title; luxemgModalImage.src = material.image; luxemgModalImage.alt = material.title; luxemgModalDescription.innerHTML = material.description; // 填充技术规格 luxemgModalSpecs.innerHTML = ''; material.specs.forEach(spec => { const row = document.createElement('tr'); row.innerHTML = ` <td>${spec.property}</td> <td>${spec.value}</td> `; luxemgModalSpecs.appendChild(row); }); // 显示模态框 luxemgModalContainer.style.display = 'block'; // 强制重绘确保动画执行 void luxemgModalContainer.offsetWidth; // 应用显示动画 setTimeout(() => { luxemgModalContainer.style.opacity = '1'; modalContent.style.transform = 'scale(1)'; modalContent.style.opacity = '1'; }, 10); // 禁止背景滚动 document.body.style.overflow = 'hidden'; } // 关闭模态框函数 function closeLuxemgModal() { const modalContent = luxemgModalContainer.querySelector('.luxemg-modal-content'); luxemgModalContainer.style.opacity = '0'; modalContent.style.transform = 'scale(0.95)'; modalContent.style.opacity = '0'; setTimeout(() => { luxemgModalContainer.style.display = 'none'; document.body.style.overflow = ''; }, 300); } // 事件绑定函数 function initLuxemgGallery() { // 绑定关闭按钮 luxemgCloseModal.addEventListener('click', closeLuxemgModal); // 点击背景关闭 luxemgModalContainer.addEventListener('click', function(e) { if (e.target === this) closeLuxemgModal(); }); // ESC键关闭 document.addEventListener('keydown', function(e) { if (e.key === 'Escape') closeLuxemgModal(); }); // 绑定详情按钮 const detailButtons = document.querySelectorAll('.luxemg-detail-btn'); detailButtons.forEach(button => { button.addEventListener('click', function() { const modalId = this.getAttribute('data-luxemg-modal'); console.log("Opening modal:", modalId); openLuxemgModal(modalId); }); }); console.log("Gallery initialized. Found", detailButtons.length, "detail buttons."); } // DOM加载完成后初始化 document.addEventListener('DOMContentLoaded', initLuxemgGallery); })(); </script> </body> </html> 去掉这段代码中的卡片上的文字描述,保留标题和按钮
最新发布
06-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值