aryamansinghk's blog

By aryamansinghk, history, 2 years ago, In English

Problem link https://codeforces.me/contest/1715/problem/B

I solved the same problem using same logic. Once I directly tried to print the answers https://codeforces.me/contest/1715/submission/169136862 but got wrong answer on pretest 2.

While on other approach I stored them in an array and did the same https://codeforces.me/contest/1715/submission/169162093 and got the solution accepted. Why this happened?

Doubt solved : thanks to others for giving intuition. https://codeforces.me/blog/entry/106214?#comment-945874

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
3 2 1 5 :)

WA Code Output: 3 2 0

AC Code Output: 3 1 1

»
2 years ago, # |
Rev. 2   Vote: I like it -23 Vote: I do not like it

That's the way of life of a coder sometimes you don't know why your code didn't got accepted and sometimes you don't know why your code got accepted but in both cases you know that it was just your fate. — Some Indian Guy on Youtube

»
2 years ago, # |
  Vote: I like it 0 Vote: I do not like it

bring first if condition in while loop outside the loop. It should run only once. In while loop, it may risk running more than once if after first iteration, s is still greater or equal to b*k.