Tanky WooRSS

POJ 3299 Humidex

29 Jun 2010
这篇博客是从旧博客 WordPress 迁移过来,内容可能存在转换异常。

完全的水题,题目繁多,不必去理解,只需要推导公式即可。 具体可以看讨论:

http://www.cppleyuan.com/viewthread.php?tid=917&extra=page%3D1

 #include 
#include 
using namespace std;

const double e = 2.718281828;

double fun1(double h, double d)//求T
{
 return h - (0.5555 * ((6.11 * pow(e, 5417.7530*(1/273.16-1/(d+273.16)))) - 10.0));
}

double fun2(double t, double d)//求H
{
    return t + (0.5555 * ((6.11*pow(e,5417.7530*(1/273.16-1/(d+273.16)))) - 10.0));
}

double fun3(double t, double h)//求D
{
    return 1/(1/273.16 - log(((h-t)/0.5555+10.0)/6.11)/5417.7530) - 273.16;
}

int main()
{
    char a1,a2;
    double t1,t2;
    while(scanf("%c", &a1;) && a1 != 'E')
    {
        scanf("%lf %c %lf", &t1;, &a2;, &t2;);
        //printf("%c %lf %c %lf\n", a1, t1, a2, t2);
        //输出
        //数据前后顺序,如T 30 D 15和D 15 T 30答案应该一样
        if(a1=='D'&&a2;=='H')
            printf("T %.1f D %.1f H %.1f\n",fun1(t2,t1),t1,t2);
        else if(a1=='H'&&a2;=='D')
            printf("T %.1f D %.1f H %.1f\n",fun1(t1,t2),t2,t1);
        else if(a1=='T'&&a2;=='D')
            printf("T %.1f D %.1f H %.1f\n",t1,t2,fun2(t1,t2));
        else if(a1=='D'&&a2;=='T')
            printf("T %.1f D %.1f H %.1f\n",t2,t1,fun2(t2,t1));
        else if(a1=='T'&&a2;=='H')
            printf("T %.1f D %.1f H %.1f\n",t1,fun3(t1,t2),t2);
        else if(a1=='H'&&a2;=='T')
            printf("T %.1f D %.1f H %.1f\n",t2,fun3(t2,t1),t1);   
    }
    return 0;
}