For the problem UVa-579 I get AC if I use ((h*60)*0.5)+(m*0.5)-(m*6) for calculation, but if I use (h*30+m/2)-(m*6) I get WA. I know that it's something about precision problem (like comparison), but answer is printed with 3 digits after decimal point; so I didn't think this kind of change in calculation would be a problem. I don't know what's the best way for this kind of calculations. How should I calculate?
Do you read h and m as integers or as floats?
In the second formula m/2 would evaluate to an integer if m is of integer type. To avoid that either change the type of m or use m/2.0 which will show that you require floating type result :)
Sorry, I typed that wrong. Actually I use 2.0 but I get WA
Can you post the actual program. That might help making it clear what the issue is.
Can you also post the code that got AC?
Rest is the same.
You must have had a mistake somewhere else. I get AC for both versions of your code.
Also, there is no reason for the code to be imprecise -- each value is either an integer or an integer_and_a_half, and those can be represented exactly in a double. There are no precision errors anywhere.
My best guess at the moment is that Enchom was right and that the version that got WA actually used integer division by accident.
can u try this one (h*30+(m*0.5))-(m*6) , I wonder