zoukankan      html  css  js  c++  java
  • 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 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

    3.思路:

    数学题,已知两变量,求另一变量

    4.代码:

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cmath>
     4 #include <iomanip>
     5 
     6 using namespace std;
     7 
     8 //humidex = temperature + h
     9 //h = (0.5555)× (e - 10.0)
    10 //e = 6.11 × exp [5417.7530 × ((1/273.16) - (1/(dewpoint+273.16)))]
    11 
    12 int main()
    13 {
    14     //freopen("D://input.txt","r",stdin);
    15     
    16     int i;
    17     
    18     double humidex,dewpoint,temperature;
    19     char ch;
    20     int mark;
    21     
    22     while(1)
    23     {
    24         mark = 0;
    25         for(i = 0; i < 2; ++i)
    26         {
    27             cin >> ch;
    28             if(ch == 'E') 
    29             {
    30                 return 0;
    31             }
    32             else if(ch == 'T')
    33             {
    34                 cin >> temperature;
    35                 mark += 1;
    36             }
    37             else if(ch == 'D')
    38             {
    39                 cin >> dewpoint;
    40                 mark += 2;
    41             }
    42             else
    43             {
    44                 cin >> humidex;
    45                 mark += 4;
    46             }
    47         } 
    48         
    49         double h,e; 
    50         if(mark == 3)
    51         {
    52             e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dewpoint+273.16))));
    53             h = (0.5555) * (e - 10.0);
    54             humidex = temperature + h;
    55         }
    56         else if(mark == 5)
    57         {
    58             h = humidex - temperature;
    59             e = h / 0.5555 + 10.0;
    60             dewpoint = 1 / ((1 / 273.16) - log(e / 6.11) / 5417.7530) - 273.16;
    61         }
    62         else
    63         {
    64             e = 6.11 * exp (5417.7530 * ((1/273.16) - (1/(dewpoint+273.16))));
    65             h = (0.5555) * (e - 10.0);
    66             temperature = humidex - h;
    67         }
    68         
    69         //T number D number H number
    70         cout << fixed << setprecision(1); 
    71         cout << "T " << temperature << " D " << dewpoint << " H " << humidex << endl; 
    72     }
    73     
    74     return 0;
    75 } 

     5.参考资料

    http://blog.csdn.net/lijiecsu/article/details/7396711

    http://blog.csdn.net/lyy289065406/article/details/6642582

  • 相关阅读:
    unicode utf-8 ascll
    解压赋值。django导读,http协议,
    手撸orm
    优酷oneday 元类单例 多路复用
    前后台交互, 按钮, 输入栏,列表,选项 ,dom
    jq 事件;jq选择器,与js转化,jq操作文档,属性,类名,全局变量;获取盒子信息
    事件补充;对象操作;字符串类型操作;数组操作;数字类型操作
    if结构 ,循环结构,数据类型转换,逻辑运算符;三个弹出窗口;计算后样式获取,修改;函数
    js 引入与选择器;对文档修改;数据类型基础语法;计算后样式
    伪类边框,字体图标,显隐,overflow,阴影,二维变形
  • 原文地址:https://www.cnblogs.com/mobileliker/p/3932590.html
Copyright © 2011-2022 走看看