Timus 1823

系统 1547 0
      
        #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多次。

Timus 1823


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论