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

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

Hi codeforces community, I'm new to codeforces and also a beginner in competitive coding.In the previous contest, i tried to solved this question . "http://mirror.codeforces.com/contest/879/problem/B ". the code run perfectly on my compiler ,but it failed to run in some test cases codeforces compiler .i tried in few other online compiler, they gave the same response as my compiler gave. My solution "http://mirror.codeforces.com/contest/879/submission/31767149". So i request if someone could help from the community.

Thank you in advance.

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

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

It's really quite obviously because K needs to be long long. On an unrelated note, I'd strongly recommend properly indenting your code; the way it's written now is basically unreadable.

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

First of all take long long int since maximum k is 1e12

Then for the case d <= c you need to do count = 1 not 0

AC Code

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

The following is a bit more readable C++11 solution for the problem.

31773713

Best wishes