POJ 3299 水题

//11363256	c00h00g	3299	Accepted	780K	0MS	G++	1173B	2013-03-18 11:58:22
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
using namespace std;
#define E 2.718281828

double get_e(double d){
    return 6.11*pow(E,5417.7530*(1/273.16-1/(d+273.16)));
}

int main(){
    char ch1,ch2;
    double num1,num2,num3;
    while(cin>>ch1&&ch1!='E'){
        cin>>num1>>ch2>>num2;
        if(ch1=='D'&&ch2=='T'){ch1='T';ch2='D';double tmp=num1;num1=num2;num2=tmp;}
        if(ch1=='T'&&ch2=='D'){
            num3=num1+0.5555*(get_e(num2)-10.0);
            printf("T %.1f D %.1f H %.1f \n",num1,num2,num3);
        }
        if(ch1=='D'&&ch2=='H'){ch1='H';ch2='D';double tmp=num1;num1=num2;num2=tmp;}
        if(ch1=='H'&&ch2=='D'){
            num3=num1-0.5555*(get_e(num2)-10.0);
            printf("T %.1f D %.1f H %.1f\n",num3,num2,num1);
        }
        if(ch1=='T'&&ch2=='H'){ch1='H';ch2='T';double tmp=num1;num1=num2;num2=tmp;}
        if(ch1=='H'&&ch2=='T'){
            double temp=log(((num1-num2)/0.5555+10.0)/6.11)/5417.7530;
            num3=1/(1/273.16-temp)-273.16;
            printf("T %.1f D %.1f H %.1f\n",num2,num3,num1);
        }
    }
    return 0;
}


你可能感兴趣的:(POJ 3299 水题)