HEU 2041 Drink, on Ice
1
/**************************************
2
Problem: HEU 2041 Drink, on Ice
3
Time: 0.0020 s
4
Memory: 288 k
5
Accepted Time: 2009-04-06 19:05:13
6
Tips: 比较"水到零度水放出的热量"和"冰到零度冰吸收的热量"
7
**************************************/
8
#include <stdio.h>
9
int main()
10
{
11
double mw,mi,tw,ti;
12
while(1)
13
{
14
scanf("%lf%lf%lf%lf",&mw,&mi,&tw,&ti);
15
if(mw==0&&mi==0&&tw==0&&ti==0)break;
16
double temp=tw*mw*4.19+ti*mi*2.09;
17
if(temp>=335.0*mi)
18
{
19
temp-=335.0*mi;
20
printf("0.0 g of ice and %.1lf g of water at %.1lf C\n",mw+mi,temp/(mw+mi)/4.19);
21
}
22
else if(temp>=0.0)
23
{
24
double t=temp/335.0;
25
printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n",mi-t,mw+t);
26
}
27
else if(-temp<=335.0*mw)
28
{
29
double t=-temp/335.0;
30
printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n",mi+t,mw-t);
31
}
32
else
33
{
34
temp+=335.0*mw;
35
printf("%.1lf g of ice and 0.0 g of water at %.1lf C\n",mw+mi,temp/(mw+mi)/2.09);
36
}
37
}
38
return 0;
39
}
40
/**************************************2
Problem: HEU 2041 Drink, on Ice3
Time: 0.0020 s4
Memory: 288 k 5
Accepted Time: 2009-04-06 19:05:136
Tips: 比较"水到零度水放出的热量"和"冰到零度冰吸收的热量" 7
**************************************/8
#include <stdio.h>9
int main()10
{11
double mw,mi,tw,ti;12
while(1)13
{14
scanf("%lf%lf%lf%lf",&mw,&mi,&tw,&ti);15
if(mw==0&&mi==0&&tw==0&&ti==0)break;16
double temp=tw*mw*4.19+ti*mi*2.09;17
if(temp>=335.0*mi)18
{19
temp-=335.0*mi;20
printf("0.0 g of ice and %.1lf g of water at %.1lf C\n",mw+mi,temp/(mw+mi)/4.19);21
}22
else if(temp>=0.0)23
{24
double t=temp/335.0;25
printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n",mi-t,mw+t);26
}27
else if(-temp<=335.0*mw)28
{29
double t=-temp/335.0;30
printf("%.1lf g of ice and %.1lf g of water at 0.0 C\n",mi+t,mw-t);31
}32
else33
{34
temp+=335.0*mw;35
printf("%.1lf g of ice and 0.0 g of water at %.1lf C\n",mw+mi,temp/(mw+mi)/2.09);36
}37
}38
return 0;39
}40




浙公网安备 33010602011771号