Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
[不用那么麻烦,三种情况讨论一下就可以了#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator