#include #include #include #define abs(x) ((x) > 0 ? (x) : -(x)) #define eps(x) (abs(x) > 1e-6) int main() { double mw, mi, tw, ti; close(0); open("drink.in", O_RDONLY); while (scanf("%lf%lf%lf%lf", &mw, &mi, &tw, &ti), eps(mw) || eps(mi) || eps(tw) || eps(ti)) { double ew = mw * (4.19 * tw + 335 + 30.0 * 2.09); double ei = mi * (ti + 30.0) * 2.09; double epg = (ew + ei) / (mw + mi); if (epg <= 30.0 * 2.09) { printf("%.1lf g of ice and 0.0 g of water at %.1lf C\n", mw + mi, -((30.0 * 2.09 - epg) / 2.09)); } else if (epg >= 30.0 * 2.09 + 335) { printf("0.0 g of ice and %.1lf g of water at %.1lf C\n", mw + mi, (epg - (30.0 * 2.09 + 335)) / 4.19); } else { double er = epg - 30.0 * 2.09; double w = (mw + mi) * er / 335.0; printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n", mw + mi - w, w); } } return 0; }