POJ3299 Humidex 简单二分

poj3299 Humidex(公式直接算) 水题 有一丢丢技巧的输入,再带上三个个公式的计算 代码思路和格式蛮漂亮的,可以借鉴 #include<iostream> #include<cmath> #define exp 2.718281828 using namespace std; double geth(double t,double d){ double h,e; e=6.11*pow(exp,5417.7530*((1/273.16)-(1/(d+273.16)))); h=0.5555*(e-10); r 阅读详情

求humidex和temperature的时候就是简单的运用他给你的公式,这里要记住exp()函数的功能是求e的x次方。

当求dewpoint ,我们只要二分,并利用humidex和temperature中的任何一个计算另一个值,观察是否相等,因为在【-100,100】区间范围之内,函数是个单调函数,所以可以根据此来二分。

 

Humidex

Time Limit: 1000MS

 

Memory Limit: 65536K

Total Submissions: 12382

 

Accepted: 4597

Description

Adapted from Wikipedia, the free encyclopedia

The humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the heat index used in the United States in using dew point rather than relative humidity.

When the temperature is 30°C (86°F) and the dew point is 15°C (59°F), the humidex is 34 (note that humidex is a dimensionless number, but that the number indicates an approximate temperature in C). If the temperature remains 30°C and the dew point rises to 25°C (77°F), the humidex rises to 42.3.

The humidex tends to be higher than the U.S. heat index at equal temperature and relative humidity.

The current formula for determining the humidex was developed by J.M. Masterton and F.A. Richardson of Canada's Atmospheric Environment Service in 1979.

According to the Meteorological Service of Canada, a humidex of at least 40 causes "great discomfort" and above 45 is "dangerous." When the humidex hits 54, heat stroke is imminent.

The record humidex in Canada occurred on June 20, 1953, when Windsor, Ontario hit 52.1. (The residents of Windsor would not have known this at the time, since the humidex had yet to be invented.) More recently, the humidex reached 50 on July 14, 1995 in both Windsor and Toronto.

The humidex formula is as follows:

humidex = temperature + h
h = (0.5555)× (e - 10.0)
e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
where exp(x) is 2.718281828 raised to the exponent x.

While humidex is just a number, radio announcers often announce it as if it were the temperature, e.g. "It's 47 degrees out there ... [pause] .. with the humidex,". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex, but rarely do they report all three measurements. Write a program that, given any two of the measurements, will calculate the third.

You may assume that for all inputs, the temperature, dewpoint, and humidex are all between -100°C and 100°C.

Input

Input will consist of a number of lines. Each line except the last will consist of four items separated by spaces: a letter, a number, a second letter, and a second number. Each letter specifies the meaning of the number that follows it, and will be either T, indicating temperature, D, indicating dewpoint, or H, indicating humidex. The last line of input will consist of the single letter E.

Output

For each line of input except the last, produce one line of output. Each line of output should have the form:

T number D number H number
where the three numbers are replaced with the temperature, dewpoint, and humidex. Each value should be expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures are in degrees celsius.

Sample Input

T 30 D 15
T 30.0 D 25.0
E

Sample Output

T 30.0 D 15.0 H 34.0
T 30.0 D 25.0 H 42.3

Source

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

#define eps 1e-8
map<char,double> mci;
map<char,bool> jud;

double humi()
{
    double e,h;
    e=6.11*exp(5417.7530*((1/273.16)-(1/(mci['D']+273.16))));
    h=0.5555*(e-10.0);
    return mci['T']+h;
}

double temp()
{
    double e,h;
    e=6.11*exp(5417.7530*((1/273.16)-(1/(mci['D']+273.16))));
    h=0.5555*(e-10.0);
    return mci['H']-h;
}

double dew()
{
    double l=-100,r=100,m;
    while(l+eps<r)
    {
        m=(l+r)/2;
        mci['D']=m;
        if(mci['H']>humi())
            l=m;
        else
            r=m;
    }
    return r;
}

int main()
{
    char s[5];
    mci['D']=mci['H']=mci['T']=0;
    while(1)
    {
        jud['D']=jud['H']=jud['T']=0;
        scanf("%s",s);
        if(s[0]=='E') break;
        scanf("%lf",&mci[s[0]]);
        jud[s[0]]=1;
        scanf("%s",s);
        scanf("%lf",&mci[s[0]]);
        jud[s[0]]=1;
        if(!jud['D']) mci['D']=dew();
        if(!jud['H']) mci['H']=humi();
        if(!jud['T']) mci['T']=temp();
        printf("T %.1lf D %.1lf H %.1lf\n",mci['T'],mci['D'],mci['H']);
    }
    return 0;
}


 

北大POJ3299-Humidex编程题解 POJ在线判题系统中的题目涵盖范围广泛,从基础算法到复杂的数据结构设计,旨在锻炼参与者的编程思维与编码能力。这些题目不仅有助于理解理论知识,而且还培养了解决实际问题的能力。题目编号3299通常代表POJ中的一个具体编程挑战题目。这个特定的题目可能是关于算法设计、数据结构应用、数学问题、字符串处理等方面的一个具体实例。此题目旨在考察参与者对于特定编程问题的理解,以及使用计算机语言实现解决方案的能力。题目编号3299是POJ(北京大学在线评测系统)中的一个典型算法问题。 阅读详情

相关推荐

MIT操作系统课程JOS实验讲义(1-7章)

MIT6.828操作系统课程的中文讲义。这个资料比较系统,比官网的英文书更好,可以与官网英文书互为补充。

poj 3299 Humidex

Humidex Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9883 Accepted: 3755 Description Adapted from Wikipedia, the free encyclopedia The humidex is a mea...

weixin_30955341的博客 305

Humidex:湿度指数(“湿度指数”的缩写)是一种用于通过结合热和湿度的影响来描述普通人感觉天气有多热的量表。 (这是加拿大 Humidex 不是美国热量指数)

Humidex 湿度指数(“湿度指数”的缩写)是一种用于通过结合热和湿度的影响来描述普通人感觉天气有多热的量表。 (这是加拿大 Humidex 不是美国热量指数)。 您可以在查看正在运行的 PHP 示例代码。 我最初编写这个软件是我在 2015 年夏季从事的物联网项目的一部分,但我找不到可以计算 Humidex 的 PHP 代码,所以我发布了我自己的版本。 感谢您花时间看这个项目,希望对您有用, 康纳沃尔什。

poj-3299 Humidex 水题,推公式

poj-3299 Humidex

Nervending的 591

Prompt Learning 简介

• Prompt Learning 可以将所有的任务归一化预训练语言模型的任务• 避免了预训练和fine-tuning 之间的gap,几乎所有 NLP 任务都可以直接使用,不需要训练数据。• 在少样本的数据集上,能取得超过fine-tuning的效果。• 使得所有的任务在方法上变得一致。

jxsdq的博客 1万+

以太网物理层协议整理(2)-万兆以太网

在万兆以太网标准化过程中,IEEE和10GEA(万兆以太网联盟)是两个最重要的组织。 万兆以太网标准和规范都比较繁多,在标准方面,首先有2002年的IEEE 802.3ae,后来也不断有新的万兆以太网规范推出,如2006年的IEEE 802.3an标准(10GBase-T)就推出了基于双绞铜线的万兆以太网规范,同样的IEEE 802.3aq标准推出了基于光纤的10GBase-LRM;2007年的

NowOrNever 3万+

poj日记(3299)

这几天刚上手刷poj的题,先尝试一些简单题,今天3299 Description Adapted from Wikipedia, the free encyclopedia The humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and

luantai6098的博客 464

【毕设】基于LoRa的物联网控制器:从原理图到PCB的完整硬件设计指南

本文提供了一份完整的基于LoRa的物联网控制器硬件设计指南,涵盖从系统框图、原理图设计到PCB布局布线的全流程。详细讲解了电源电路、单片机最小系统、信号接口以及LoRa无线模块等核心模块的设计要点与抗干扰技巧,并分享了实用的调试心得,旨在帮助电子、物联网专业学生顺利完成毕业设计,掌握低功耗远距离物联网节点的硬件开发实践。

weixin_42126677的博客 309

POJ 3299 Humidex

题目:三个变量temperature,dewpoint,humidex有以下关系: humidex = temperature + h h = (0.5555)× (e - 10.0) e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))] 任务是根据其中任意两个数,计算出第三个数。 输入:输入的每一行由

路漫漫其修远兮,吾将上下而求索 2170

Transformer实战(38)——视觉Transformer (Vision Transformer, ViT)

Transformer 在自然语言处理 (NLP) 领域取得了显著成就,在许多不同的任务中都表现出色。在本节中,我们将探索视觉 Transformer (Vision Transformer, ViT) 模型。正如 NLP 领域创建了多种模型一样,视觉领域也开发了多种模型,每种模型都为计算机视觉提供了新的视角。通过本节,将学习如何使用 ViT 等模型进行计算机视觉任务,了解基于 Transformer 的预训练计算机视觉模型的工作原理,以及如何针对特定任务进行微调。

盼小辉丶的博客 3107

基于FPGA的多级CIC滤波器实现四倍插值

基于FPGA的多级CIC滤波器实现四倍插值 原文链接:基于FPGA的多级CIC滤波器实现四倍插值 在《基于FPGA的多级CIC滤波器实现四倍抽取一》和《基于FPGA的多级CIC滤波器实现四倍抽取二》中我们先来了解滑动平均滤波器、微分器、积分器以及梳状滤波器原理以及它们的幅频响应。此篇我们将用verilog实现基于FPGA的多级CIC滤波器实现四倍插值。 1 CIC滤波器的基本概述 CIC(积分梳状...

baidu_34971492的博客 3147

Humidex POJ - 3299 (数学)

题目大意 给定你三个变量中的两个输出剩下的那一个 题解 没有什么,就是把公式推出来即可,完全的数学题 代码 #include <iostream> #include <cmath> #include <cstdio> using namespace std; int main() { /*ios::sync_with_stdio(0); cin.tie...

weixin_30871293的博客 175

YOLOv13手把手添加YOLOv13注意力机制:Biformer(BiLevelRoutingAttentio)YOLOv13双层路由注意力 革命性的高效注意力机制深度解析YOLOv13YOLOv1

YOLOv13 BiLevelRoutingAttention是一种革命性的高效注意力机制,YOLOv13通过双层路由策略显著降低了计算复杂度。YOLO它将注意力计算分为区域级路由和令牌级注意力两个层次,前者选择最相关的K个区域,后者仅在选定区域内执行注意力计算。这种设计借鉴了人类视觉系统的分层处理机制,在保持长距离依赖建模能力的同时,将复杂度从O(N²)降至O(NK + P⁴)。该机制还集成了可微分路由、自适应参数和LePE位置编码等创新技术,YOLOv13 YOLOv13 YOLOv13 YOLOv13

FJN110的博客 663

POJ 3299 Humidex Java题解

本文主要是针对POJ-3299-Humidex使用Java实现的相关过程,以及初学者的注意事项。

Exticntion的博客 750

Python 爬虫实战:爬取哔哩哔哩知识区,抓取高赞课程信息

哔哩哔哩(Bilibili)是一个广受欢迎的综合性视频社区,其中的知识区汇聚了大量优质的教育、科普、技术等课程内容。本文将指导读者如何使用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息,并进行数据分析。本文深入探究了利用 Python 爬虫技术从哔哩哔哩知识区抓取高赞课程信息的全流程。从前期的环境搭建、模拟登录,到核心的课程数据抓取、存储,再到后续的数据分析与可视化,都详细展开讲解并提供代码支持。通过此方法所获取的数据,能够助力创作者优化内容、用户发现优质课程、平台洞察用户需求。

u014481728的博客 1143

MicroBlaze系列教程(5):AXI_UART16550的使用

axi-uart16550是Xilinx的一款串口IP核,支持配置成16450或16550模式,16550和16450是指的早期电脑主板上的串口芯片型号,16550相比于16450多了FIFO,现在已经很少使用。相比于,16550支持1或2位停止位,包括uartlite所有的功能,而且支持在SDK中灵活对波特率、数据、校验方式进行配置。与uartlite不同的是,不能单独指定发送中断和接收中断函数,只有一个中断函数,通过event参数来区分当前是发送或接收中断。

whik1194的博客 4560

程序证明与形式化验证:从理论到工程实践

程序证明作为计算机科学的重要分支,旨在通过数学方法确保软件行为的绝对正确性。其核心原理是形式化验证,即使用形式化语言对系统进行精确描述,并通过逻辑推理证明其满足特定属性。这项技术的价值在于能够提供超越传统测试的逻辑完备性保证,从根本上提升软件的可信度。在工程实践中,形式化验证已应用于安全关键系统、密码学实现、操作系统内核等场景,通过自动化工具链(如SMT求解器)降低验证负担。例如,Project Everest项目采用分层验证策略,聚焦于构建完全形式化验证的HTTPS协议栈,为互联网安全通信打造数学意义上的

weixin_30325971的博客 362

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

POJ3299 -- Humidex

POJ3299 -- Humidex Submit1:Wrong Answer #include #include int main(){ char flag; double temperature,dew_point; while(scanf("%c",&flag)!=EOF&&flag!='E'){ scanf(" %lf D %lf",&t

360

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

POJ3299 Humidex

//1_4_2: Humidex 湿热指数,温度和露点之间的关系 POJ3299 #include #include #include #include using namespace std; double get_hum(double tem,double dew) { return tem + 0.5555 * (6.11 * exp(5417.7530 * ((1 / 273.1

364

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Poj 3299 Humidex

1.链接: http://poj.org/problem?id=3299 2.题目: Humidex Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16705   Accepted: 6078 Description Adapted from Wikip

西门求雪的专栏 384

POJ 3299 - Humidex

Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15668   Accepted: 5722 Description Adapted from Wikipedia, the free encyclopedia The humidex is a measurement used by

Latte_z的小站 592

Poj3299——Humidex

题目 T he humidex is a measurement used by Canadian meteorologists to reflect the combined effect of heat and humidity. It differs from the heat index used in the United States in using dew point rath...

qq_42770849的博客 406

POJ - 3299 Humidex

Humidex Time Limit: 1000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u Submit Status Description Adapted from Wikipedia, the free encyclopedia The humidex

acm_1361677193的专栏 351
上一篇: POJ1003 Hangover 打表/二分
下一篇: POJ 1698 Alice's Chance 网络流/匹配
Albafica
博客等级 码龄16年 98粉丝 359原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值