ankitsinha3005's blog

By ankitsinha3005, history, 7 years ago, In English

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://codeforces.net/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://codeforces.net/contest/879/submission/31767149". So i request if someone could help from the community.

Thank you in advance.

  • Vote: I like it
  • -1
  • Vote: I do not like it

| Write comment?
»
7 years ago, # |
  Vote: I like it +5 Vote: I do not like it

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 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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

31773713

Best wishes