Блог пользователя praveenojha33

Автор praveenojha33, история, 6 лет назад, По-английски

Currently I was practicing in a virtual contest and for this problem https://codeforces.net/contest/1003/problem/C I got wrong answer for test case 1 ( though everything was working correctly offline and on other online compilers for same test case) after the contest when I looked at the test case and changed the header file to iostream, the same solution got Accepted. Can anyone please help me to figure out why such error occurred.

1)Link of submission getting WA verdict(with stdio.h header file):https://codeforces.net/contest/1003/submission/49744850

2)Link of same code on ideone getting correct output for same test case (with stdio.h header file): https://ideone.com/QPqinX

3)Link of same submission getting accepted using iostream header file: https://codeforces.net/contest/1003/submission/49745087

My Offline gcc version is 7.3.0(C++17) . Everything works fine on ideone also with gcc 6.3.0 (C++14)

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by praveenojha33 (previous revision, new revision, compare).

»
6 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

I think the issue is that the format "%.10Lf" for type long double is not correct with stdio.h, or there is no format for that type in stdio.h, because, if you convert long double in the first code to double you will get the correct answer, as I have just tried.

  • »
    »
    6 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

    But the above code works correctly in offline compiler and also on ideone with same GCC version. BTW I just submitted the same code by changing the long double to double and it worked with 0.10Lf having stdio.h header file so how we can say that it is supported by stdio.h header file. Link where 0.10Lf works with stdio.h : https://codeforces.net/contest/1003/submission/49748316

    • »
      »
      »
      6 лет назад, # ^ |
      Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

      Yes, I meant that it will work because of supporting double and not supporting long double.

      My local test (on my laptop) gives the same results as Codeforces for G++14, so, are there different versions of G++14 between your local and Codeforces? I don't know.