#include #include #include #include #include #include using namespace std; ifstream in("drink.in"); int main() { while (1) { double ice, water, t_ice, t_water; in >> water >> ice >> t_water >> t_ice; double total = water + ice; if (water + ice == 0) break; double energy = water * t_water * 4.19 + ice * t_ice * 2.09 - ice * 335.0; double t; if (energy > 0) { t = energy / 4.19 / total; water = total; ice = 0; } else if (energy < -335.0 * total) { ice = total; water = 0; energy += 335.0 * total; t = energy / 2.09 / total; } else { t = 0; ice = -energy / 335.0; water = total - ice; } printf("%.1f g of ice and %.1f g of water at %.1f C\n", ice, water, t); } return 0; }