Hello,
I'm trying to solve the B problem of the Div2 Round #382.
I'm getting the correct answer when i compile on my system with gcc version 5.3.1 but when i submit I get WA on the very first test case. Om my system i get "6.00000000", which is the right answer, but when i submit i get a "0.00000000".Can anybody help me?
Problem statement: http://mirror.codeforces.com/contest/735/problem/B Submission: http://mirror.codeforces.com/contest/735/submission/22645993
Thanks in Advance :)
Try submitting in c++14 instead of C11.
Maybe the results are different since
qsort
is a randomized algorithm.The problem is that you're using
%lf
in theprintf
when you should use%f
.Note that
%lf
is only used for doubles inscanf
.http://en.cppreference.com/w/c/io/fprintf
Although it has erroneous behavior in submission, "%lf" is also permitted since C99.
Interesting. I normally don't use C. So, it seems GCC 5.3 is not respecting the change in the standard, right?
I'm trying but can't figure out why it is happening... My GCC works well with that, even with -std=c89. We might need exact compile option/environment to know what the problem is.
Probably MINGW being crazy as usual with format specifiers. It's even worse than this actually, because if you don't submit with C++14, then you must use "%lf" for scanf and "%f" for printf.
It's interesting why GCC GNU C11 works strange. Use GCC C++. Bad news for you: your algo is wrong (may be). See my submission: http://mirror.codeforces.com/contest/735/submission/22649713 upd: Sorry, your algo is right, only need to use long long for 'a' and 'b' variables :) see http://mirror.codeforces.com/contest/735/submission/22649947
GNU C11 AC! To change %ld --> %d and %.8lf --> %.8f . http://mirror.codeforces.com/contest/735/submission/22650004
finally: http://mirror.codeforces.com/contest/735/submission/22650016 was changed %.8lf --> %.8f only!