POJ 3299 Humidex
Posted Annetree的博客
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了POJ 3299 Humidex相关的知识,希望对你有一定的参考价值。
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 + hwhere exp(x) is 2.718281828 raised to the exponent x.
h = (0.5555)× (e - 10.0)
e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
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
T number D number H numberwhere 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
就是数学公式的转换,代码在G++环境下WA了,在C++环境下过了,很坑
1 #include<iostream> 2 #include<cstdio> 3 #include<queue> 4 #include<vector> 5 #include<cstring> 6 #include<string> 7 #include<algorithm> 8 #include<map> 9 #include<cmath> 10 #include<math.h> 11 using namespace std; 12 13 14 int main() 15 { 16 17 char ch1,ch2; 18 double a1,a2; 19 double a[3];//T,D,H 20 while(cin>>ch1) 21 { 22 if(ch1==‘E‘) 23 break; 24 cin>>a1>>ch2>>a2; 25 memset(a,0.0,sizeof(a)); 26 if(ch1==‘T‘) 27 a[0]=a1; 28 else if(ch1==‘D‘) 29 a[1]=a1; 30 else 31 a[2]=a1; 32 if(ch2==‘T‘) 33 a[0]=a2; 34 else if(ch2==‘D‘) 35 a[1]=a2; 36 else 37 a[2]=a2; 38 if(a[0]==0.0)//已知DH求T 39 { 40 double e=6.11 * exp(5417.7530 * ((1.0/273.16) - (1.0/(a[1]+273.16)))); 41 double h=(0.5555)* (e - 10.0); 42 a[0]=a[2]-h; 43 } 44 else if(a[1]==0.0)//已知TH求D 45 { 46 double h=a[2]-a[0]; 47 double e=(h/0.5555)+10.0; 48 double p=log(e/6.11); 49 a[1]=(273.16/(1-273.16*(p/5417.7530)))-273.16; 50 } 51 else//已知DT求H 52 { 53 double e=6.11 * exp(5417.7530 * ((1.0/273.16) - (1.0/(a[1]+273.16)))); 54 double h=(0.5555)* (e - 10.0); 55 a[2]=a[0]+h; 56 } 57 58 printf("T %.1lf D %.1lf H %.1lf\n",a[0],a[1],a[2]); 59 } 60 return 0; 61 }
以上是关于POJ 3299 Humidex的主要内容,如果未能解决你的问题,请参考以下文章