Whenever one uses floating point operations, he should always think about the potential precision errors they may get, shouldn't he? Just think about all those problems unsolvable by float but solvable by double.
I think that there's a difference between "you use floats instead of doubles, get a precision loss of 1e-2 in the worst case, and thus fail" and "you get a precision loss of 1e-15 due to the fact that some real numbers cannot be represented exactly, and thus get a WA". In the first case, it's the problem solver's mistake. In the second case, it's just a nuisance that will make people spend hours looking for bugs they didn't make. They computed the exact answer as precisely as it could be represented, but still they don't get their AC just because they are printing it wrong.
I agree that no floating point operations are necessary. What I originally did in my solution was the following:
Code: Select all
// .. compute the count of good numbers (IMHO this is what the task is about)
good = ...
// now print the result
printf("%.2f\n",100.0 * good / all);
To get AC I had to:
- browse the old discussions at the forums
- find out about the rejudging
- change the one "printf" line into several statements that did the rounding manually
I think that in general "computing the answer", and not "printing the answer" should be the hard part of the problem. If this is not the case, the problem statement should be specific about it.
Either way, for this problem the problem statement as is is too vague, it doesn't specify the rounding mode, and the solver must guess
the correct interpretation. This is never a good thing.