### beethoven97's blog

By beethoven97, history, 8 days ago,

I know that this problem supposed to be a trivial problem , but I stay in it about 1 hour and i don't know why it get WA on test 3 about 10 times of submissions and i submitted the solution with python and c++ as i thought that WA is due to precision error but both of them didn't get accepted.

c++ code
python code

• +3

 » 8 days ago, # |   +6 It is about rounding, you have to set value = (dist * 1000.0) / (331.3 + .606 * temp), and then to round you have to floor(value*100+0.5)/100; Then it gets AC.
•  » » 8 days ago, # ^ |   +3 thank you, my code get accepted in python and c++ also.
•  » » 7 days ago, # ^ |   +3 This still gives me wrong answer. What am I doing wrong? Code#include #include #include using namespace std; int main() { int tt; cin >> tt; while(tt--) { long double temp, dist; cin >> temp >> dist; long double value = (dist * 1000.0) / (331.3 + 0.606 * temp); value = floor(value * 100 + 0.5) / 100; cout << fixed << setprecision(2) << value << '\n'; } return 0; } 
•  » » » 7 days ago, # ^ |   +6 You don't use setprecision after rounding, due to it changing the answer. It gets AC when you remove fixed and setprecision(2).
•  » » » » 7 days ago, # ^ |   0 Thank you :)
•  » » » 7 days ago, # ^ |   +3 your code will be accepted if you print value without setprecision and fixed, but i don't know why these happened. accepted code#include #include #include using namespace std; int main() { int tt; cin >> tt; while(tt--) { long double temp, dist; cin >> temp >> dist; long double value = (dist * 1000.0) / (331.3 + 0.606 * temp); value = floor(value * 100 + 0.5) / 100; cout<