#include < iostream >
using namespace std;
char c1,c2,c3,c4,blank;
double d1,d2,d3,d4;
bool check( char c) {
if (c1 != c && c2 != c && c3 != c)
return true ;
return false ;
}
int main() {
double val[ 300 ] = { 0.0 }, R = 8.314 ;
cin >> c1 >> blank;
cin >> val[c1];
cin >> c2 >> blank;
cin >> val[c2];
cin >> c3 >> blank;
cin >> val[c3];
if (check( ' T ' )) {
if ((val[ ' n ' ] == 0 && val[ ' p ' ] != 0 ) || val[ ' p ' ] == 0 && val[ ' n ' ] != 0 )
printf( " error\n " );
else if (val[ ' n ' ] == 0 && val[ ' p ' ] == 0 )
printf( " undefined\n " );
/* else if(val['n'] == val['V'])
val['n'] = val['V'] = 1;
else if(val['p'] == val['n'])
val['p'] = val['n'] = 1; */
else {
val[ ' T ' ] = (val[ ' p ' ] * val[ ' V ' ]) / ( val[ ' n ' ] * R );
printf( " T = %lf\n " , val[ ' T ' ]);
/* int T = (int)(val['T'] * 10000) % 10;
if( T > 4 )
val['T'] += 0.001;
T = (int)(val['T'] * 1000);
if(T > 0)
printf("T = %lf\n", val['T']);
else
printf("error\n"); */
}
}
if (check( ' p ' )) {
if (val[ ' n ' ] == 0 )
// printf("undefined\n"); wa 12
printf( " p = 0.0000000000\n " );
/* else if(val['T'] == val['V'])
val['T'] = val['V'] = 1;
else if(val['n'] == val['V'])
val['n'] = val['V'] = 1; */
else {
val[ ' p ' ] = (val[ ' n ' ] * R * val[ ' T ' ] / val[ ' V ' ]);
printf( " p = %lf\n " , val[ ' p ' ]);
/* int p = (int)(val['p'] * 10000) % 10;
if( p > 4 )
val['p'] += 0.001;
p = (int)(val['p'] * 1000);
if(p > 0)
printf("p = %lf\n", val['p']);
else
printf("error\n"); */
}
}
if (check( ' n ' )) {
if (val[ ' p ' ] == 0 )
// printf("undefined\n"); wa 6
printf( " n = 0.0000000000\n " );
/* else if(val['T'] == val['V'])
val['T'] = val['V'] = 1;
else if(val['p'] == val['T'])
val['p'] = val['T'] = 1; */
else {
val[ ' n ' ] = (val[ ' p ' ] * val[ ' V ' ]) / (val[ ' T ' ] * R);
printf( " n = %lf\n " , val[ ' n ' ]);
/* int n = (int)(val['n'] * 10000) % 10;
if( n > 4 )
val['n'] += 0.001;
n = (int)(val['n'] * 1000);
if(n > 0)
printf("n = %lf\n", val['n']);
else
printf("error\n"); */
}
}
if (check( ' V ' )) {
if ((val[ ' n ' ] == 0 && val[ ' p ' ] != 0 ) || val[ ' p ' ] == 0 && val[ ' n ' ] != 0 )
printf( " error\n " );
else if (val[ ' n ' ] == 0 && val[ ' p ' ] == 0 ) // without this code wa 8
printf( " undefined\n " );
/* else if(val['T'] == val['p'])
val['T'] = val['p'] = 1;
else if(val['p'] == val['n'])
val['p'] = val['n'] = 1; */
else {
val[ ' V ' ] = (val[ ' n ' ] * R * val[ ' T ' ] / val[ ' p ' ]);
/* int v = (int)(val['V'] * 10000) % 10;
if( v > 4 )
val['V'] += 0.001; */
printf( " V = %lf\n " , val[ ' V ' ]);
// v = (int)(val['V'] * 1000);
// if(v > 0)
// printf("V = %lf\n", val['V']);
// else
// printf("error\n");
}
}
return 0 ;
}
这题目就是蛋疼蛋疼蛋疼, 要考虑各种参数的配合,这个都算了,竟然在我考虑了进位,计算后结果大小这些情况后反而一直WA,反正这题目是我TIMUS目前WA最多了,60多次。