[POJ3299]Humidex
2016-05-13 16:53
225 查看
Humidex
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:
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:
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
Sample Output
Source
Waterloo Local Contest, 2007.7.14
题目地址:http://poj.org/problem?id=3299
题解:就是按照给定的公式求出T D H 简单的模拟
AC代码:
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const double inf = 0x3f3f3f;
char ch, c;
double t, d, h;
void getNum(char ch, double num);
int main() {
while ((c = getchar()) != 'E') {
double a, b;
scanf(" %lf ", &a);
ch = getchar();
scanf("%lf", &b);
getchar();
t = d = h = -inf;
getNum(c, a);
getNum(ch, b);
if (h == -inf) {
double e = 6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16))));
h = 0.5555 * (e - 10.0) + t;
}
else if (d == -inf) {
double e = (h - t) / 0.5555 + 10.0;
d = 1 / (1 / 273.16 - log(e / 6.11) / 5417.7530) - 273.16;
}
else if (t == - inf) {
double e = 6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16))));
t = h - 0.5555 * (e - 10.0);
}
printf("T %.1f D %.1f H %.1f\n", t, d, h);
}
return 0;
}
void getNum(char ch, double num) {
if (ch == 'T') {
t = num;
}
else if (ch == 'D') {
d = num;
}
else {
h = num;
}
}
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 20172 | Accepted: 7268 |
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
Waterloo Local Contest, 2007.7.14
题目地址:http://poj.org/problem?id=3299
题解:就是按照给定的公式求出T D H 简单的模拟
AC代码:
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const double inf = 0x3f3f3f;
char ch, c;
double t, d, h;
void getNum(char ch, double num);
int main() {
while ((c = getchar()) != 'E') {
double a, b;
scanf(" %lf ", &a);
ch = getchar();
scanf("%lf", &b);
getchar();
t = d = h = -inf;
getNum(c, a);
getNum(ch, b);
if (h == -inf) {
double e = 6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16))));
h = 0.5555 * (e - 10.0) + t;
}
else if (d == -inf) {
double e = (h - t) / 0.5555 + 10.0;
d = 1 / (1 / 273.16 - log(e / 6.11) / 5417.7530) - 273.16;
}
else if (t == - inf) {
double e = 6.11 * exp(5417.7530 * ((1 / 273.16) - (1 / (d + 273.16))));
t = h - 0.5555 * (e - 10.0);
}
printf("T %.1f D %.1f H %.1f\n", t, d, h);
}
return 0;
}
void getNum(char ch, double num) {
if (ch == 'T') {
t = num;
}
else if (ch == 'D') {
d = num;
}
else {
h = num;
}
}
相关文章推荐
- 关于Android 使用服务器公钥RSA加密 数据到服务器RSA解密报错问题
- Project network redundant , Vmware virtualization, Dell VRTX P2V - Part 3 (VRTX Installation)
- css之学习
- hdu 3715 hdu 1816 hdu 4115 (2-sat)
- 常见排序之一(冒泡排序、简单选择排序)
- 实例讲解Jquery中隐藏hide、显示show、切换toggle的用法
- iOS 开发,xcode7中用QQ授权登录遇到的一些问题 QQ登录不跳客户端
- 二进制倒序算法
- 一名前端Web架构师的成长之路(转载)
- java的基本类型的长度
- 在CentOS上部署JAVA服务
- freemarker 修改功能的时候,原始数据是list 然后修改之前的数据也是list 怎么让他选中
- 是时候 UWP 了 !
- window.onload绑定多个事件 —— 两种解决方案
- 一套简单可依赖的Javascript库
- 【解决问题】windows下配置Boost提示'cl' 不是内部或外部命令,也不是可运行的程序 或批处理文件
- android保存文件到sd卡,读取和清空记录功能(可以用来保存用户名和密码)
- Action中使用session方法
- spring MVC入门教程
- 第三篇博客