There is a contest! | В настоящий момент идёт турнир. Некоторая информация и функции сервера недоступны до его окончания.
|
|
Ani | Nov.10.2015 at 08:48:19 PM | |
0 | --- Test case 1 --- 20 72 74
--- Pattern--- Failed
|
imesecan | Nov.21.2015 at 08:48:34 AM | |
1 | When calculating averages you need to pay attention integer floating point operations. integer divided by integer does integer division operation. In integer division floating point part is omitted. For example in the expression: float x; x= 9 / 10; x will be 0.
If you want to force to have floating point result, you need to typecast
float x; x=(float)9/10; x will be 0.9
|
imesecan | Nov.29.2015 at 11:10:34 PM | |
2 | If you use (float) in the beginning, it will not work: A=(float)F*45/100 + M*35/100 + H*2/10; as you can see the equation can be divided into three summation sections (multiplication and division operations have higher priority so, they are first calculated, then summations)
The second and third sections (M*35/100 + H*2/10) are integer operations. then the sums will be floating point. You should better use A = F*0.45 + M*0.35 + H*0.2;
|
|