Humidex
| Time Limit: 1000MS |
|
Memory Limit: 65536K |
| Total Submissions: 20149 |
|
Accepted: 7257 |
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 same states in using dew point rather than relative humidity.
When the temperature was 30°c (86°F) and the dew point was 15°c (59°F), the Humidex is-a humidex (note that dimensionl ESS number, but the number indicates a 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 is developed by J.M. Masterton and F.A. Richardson of Canada ' s Atmospheri C Environment Service in 1979.
According to the meteorological Service of Canada, a humidex of at least causes "great discomfort" and above "Dan Gerous. " When the humidex hits, heat stroke is imminent.
The record humidex in Canada occurred on June, 1953, when Windsor, Ontario hit 52.1. (The residents of Windsor would not having known this on the time, since the humidex had yet to be invented.) More recently, the Humidex reached to July, 1995 in both Windsor and Toronto.
The Humidex formula is as follows:
Humidex = temperature + hh = (0.5555) x (e-10.0) e = 6.11xexp [5417.7530x ((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 degrees ou T there ... [Pause].. With the Humidex, ". Sometimes weather reports give the temperature and dewpoint, or the temperature and humidex, but rarely does they report all Three measurements. Write A program this, given any of the measurements, would calculate the third.
You may assume the to all inputs, the temperature, dewpoint, and Humidex is all between-100°c and 100°c.
Input
Input would consist of a number of lines. Each line except the last would consist of four items separated by spaces:a letter, a number, a second letter, and a secon D number. Each letter specifies the meaning of the number that follows it, and would be either T, indicating temperature, D, Indicati Ng Dewpoint, or H, indicating humidex. The last line of input would 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 has the form:
Number Number Number
Where the three numbers is replaced with the temperature, dewpoint, and Humidex. Each value should is expressed rounded to the nearest tenth of a degree, with exactly one digit after the decimal point. All temperatures is in degrees Celsius.
Sample Input
T-D 15T 30.0 D 25.0E
Sample Output
T 30.0 D 15.0 H 34.0T 30.0 D 25.0 H 42.3
Source
Waterloo Local Contest, 2007.7.14
Relatively simple problem, mainly is the deformation of the mathematical formula;
#include <iostream> #include <cstring> #include <string> #include <algorithm> #include < cstdio> #include <cmath> #include <iomanip>using namespace Std;bool vis[3];int main () {double t,d,h; Char flag[2]; Double temp[2]; while (scanf ("%c", &flag[0])!=eof&&flag[0]!= ' E ') {memset (vis,0,sizeof (VIS)); scanf ("%lf%c%lf", &temp[0],&flag[1],&temp[1]); for (int i=0;i<2;++i) {if (flag[i]== ' T ') {t=temp[i]; Vis[0]=1; } else if (flag[i]== ' D ') {d=temp[i]; Vis[1]=1; } else {h=temp[i]; Vis[2]=1; }} int sign; for (int i=0;i<3;++i) {if (!vis[i]) sign=i; } switch (sign) {case 0:t=h-0.5555* (6.11*exp (5417.7530* (1/273.16-1/(d+273.16)))-10.0); Break Case 1:d=1/(1/273.16-log (((H-T)/0.5555+10)/6.11)/5417.753)-273.16; Break Case 2:h=t+0.5555* (6.11*exp (5417.7530* (1/273.16-1/(d+273.16)))-10.0); } cout<<setprecision (1) <<fixed<< "T" <<t<< "D" <<d<< "H" <
POJ 3299 Humidex