Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

负号运算符不是取相反数?

Posted by fengbenben1987 at 2011-09-20 10:58:14 on Problem 2555
一个WA, 一个AC,不同在于:

4,5c4,5
< Memory: N/A           Time: N/A
< Language: GCC         Result: Wrong Answer
---
> Memory: 404K          Time: 0MS
> Language: GCC         Result: Accepted
31c31
<                       t = (mi*335-mi*ti*2.09-mw*4.19*tw)/(-mwater*4.19);
---
>                       t = (-mi*335+mi*ti*2.09+mw*4.19*tw)/(mwater*4.19);
对这个负号运算符了解真不多啊,谁能解释一下?
WA代码:

Source Code

Problem: 2555		User: fengbenben1987
Memory: N/A		Time: N/A
Language: GCC		Result: Wrong Answer
Source Code
#include <stdio.h>


/*********************
mwater+mice = mw + mi;

mw*tw*4.19 + mi*ti*2.09 =
mwater * t * 4.19 + mice * t * 2.09 + (mwater - mw) * 335
*********************/

int main()
{
	float mw,mi,tw,ti;
	float t,mwater,mice;
	while (1){
		scanf("%f %f %f %f",&mw,&mi,&tw,&ti);
		if (-0.00001<mw&& mw<0.00001 && mi>-0.00001 && mi<0.00001 && tw>-0.00001 && tw <0.000001 && ti>-0.00001&& ti<0.00001){
			break;
		}
		
		if (mw*tw*4.19 + mi*ti*2.09 -335 * mi >= 0){ 
			mice = 0.0;
			mwater = mw+mi;
			/* mi*335+mi*t*4.19-mi*ti*2.09=mw*4.19*(tw-t)*/
			t = (mi*335-mi*ti*2.09-mw*4.19*tw)/(-mwater*4.19);

		}else if (mw*tw*4.19 + mi*ti*2.09 + 335*mw <= 0){
			mwater = 0.0;
			mice = mw + mi;
			t = (mw*tw*4.19+mi*ti*2.09+mw*335)/(mice*2.09);
			
		}else {
			t = 0.0;
			mwater = (mw*tw*4.19+mi*ti*2.09)/335+mw;
			mice = mw+mi - mwater;
			
		}
		printf("%.1f g of ice and %.1f g of water at %.1f C\n",mice,mwater,t);
	}
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator