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 WilliamACM at 2012-10-07 20:01:45 on Problem 2555
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
const double cw=4.19,ci=2.09,em=335;

double mw,mi,tw,ti;
double Q;
void solve()
{
    Q=(mw)*(ci*30+em+cw*tw)+mi*ci*(30+ti);
//    cout<<Q<<endl;
    double m=(mw+mi);
    if(m*ci*30>Q)
    {
        double T=Q/m/ci-30;
        printf("%.1f g of ice and 0.0 g of water at %.1f C",m,T);
        return ;
    }
    if(m*(ci*30+em)<Q)
    {
        double T=(Q-m*(ci*30+em))/m/cw;
        printf("0.0 g of ice and %.1f g of water at %.1f C",m,T);
        return ;
    }
    Q-=m*ci*30;
    double x=Q/em;
    printf("%.1f g of ice and %.1f g of water at 0.0 C",m-x,x);
}
int main()
{
    freopen("in.txt","r",stdin);
    while(scanf("%lf%lf%lf%lf",&mw,&mi,&tw,&ti),mw+mi)
    {
        solve();
        puts("");
    }
    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