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

Re:why WA ?

Posted by syh791180600 at 2010-04-22 16:10:15 on Problem 2555
In Reply To:why WA ? Posted by:syh791180600 at 2010-04-22 14:59:18
我改进了一下还是错……
#include <iostream>
#include <iomanip>
#define CW 4.19
#define CI  2.09 
#define em 335
using namespace std ;
int main()
{
	double mw = 0 , mi = 0 ;
	double tw = 0 , ti = 0 ;							  
	double t_finnal = 0 ;
	while (cin >> mw >> mi >> tw >> ti)
	{
		if (mw == 0 && mi == 0 && tw == 0 && ti == 0)
		{
			break ;
		} 
		else
		{
			if (mi == 0)
			{
				cout << "0.0 g of ice and " << fixed << setprecision(1)	<< mw << " g of water at " 
					<< setprecision(1) << tw <<" C" << endl ;
			}
			else
			{
				if (tw > 0)
				{
					if (ti < 0)
					{
						if ((mw * tw * CW) > (mi * (- ti) * CI + mi * em))
						{
							t_finnal = (mw * CW * tw - mi * em + mi * CI * ti) / (mi  * CW + mw * CW ) ;
							cout << "0.0 g of ice and " <<fixed << setprecision(1) << mw + mi <<" g of water at " <<
								fixed << setprecision(1) << t_finnal << " C" << endl ; 
						}
						else if ((mw * tw * CW) == (mi * (- ti) * CI + mi * em))
						{
							cout << "0.0 g of ice and "	<< fixed << setprecision(1) << mw + mi 
								<< " g of water at 0.0 C" << endl ;
						}
						else if ((mw * tw * CW) < (mi * (- ti) * CI + mi * em))
						{
							if (mw * CW * tw >= mi * (- ti) * CI)
							{
								cout << fixed << setprecision(1) << mi - ((mw * CW * tw + mi * ti * CI) / em)
									<<" g of ice and " <<fixed << setprecision(1) <<mw + ((mw * CW * tw + mi * ti * CI) / em) 
									<< " g of water at 0.0 C" << endl ;
							}
							else if (mw * CW * tw < mi * (- ti) * CI)
							{
								t_finnal = (mw * CW * tw + mw * em + mi * CI * ti) / (mi * CI + mw * CI) ;
								cout << fixed <<setprecision(1) << mi + mw << " g of ice and " << "0.0 g of water at " 
									<< fixed << setprecision(1) << t_finnal << " C" << endl ;
							}
						}
					}
					else if (ti == 0)
					{
						if (mw * CW * tw > mi * em)
						{
							t_finnal = (mi * CW * tw - mi *em) / (mw * CW + mi * CW) ;
							cout << "0.0 g of ice and "	<< fixed << setprecision(1) << mi + mw 
								<< " g of water at " <<setprecision(1) <<t_finnal << " C" << endl ;
						} 
						else if (mw * CW * tw == mi * em)
						{
							cout << "0.0 g of ice and " << fixed << setprecision(1)	<< mi + mw
								<< " g of water at 0.0 C" << endl ;
						}
						else
						{
							cout << fixed << setprecision(1) << mi - (mw * CW * tw ) / em 
								<< " g of ice and " << setprecision(1) << mw + (mw * CW * tw ) / em 
								<< " g of water at 0.0 C" << endl ;
						}
					}
				} 
				else if(tw == 0)
				{
					if (ti < 0)
					{
						if (mw * em >= mi * (- ti) * CI)
						{
							cout << fixed << setprecision(1) << mi - (mi * ti * CI) / em 
								<< " g of ice and " << setprecision(1) << mw + (mi * ti * CI) / em
								<< " g of water at 0.0 C" << endl ;
						}
						else
						{
							t_finnal = (mw * em + mi * CI * ti) / (mi * CI + mw * CI ) ;
							cout << fixed << setprecision(1) << mi + mw << 
								" g of ice and 0.0 g of water at " << setprecision(1) << t_finnal << endl ;
						}
					}
				}

			}
		}
	}
	return 0 ;
}

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