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

Автор dang7rickroll, история, 3 года назад, По-английски

if you are reading this blog, hi.

I have some problems with the "Div. 7" problem:

Here is the official code (from BledDest):

Code

And here is my c++ code when I try to translate from Python $$$\rightarrow$$$ C++:

Code

But, when I submit my C++ code, it gets the wrong answer on test 2 (on test case 52), you can check: 145516095

If you understand the reason why you can comment under this blog. Thank you very much for your help!

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

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

If you want to know the difference between your code and the python one then the difference is that the python one runs from 0 to 9(NOT INCLUDING 10) but yours does include 10 . I think that would fix your problem.

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

Your code runs for j from 0 to 10 so for example if n==61 then your code will check for 60%7==0, 61%7==0, 62%7==0 and so on till 70%7==0. Now you want the answer to be 63 but since you don't have a break statement at 70 it will it is divisible by 7 so it will update res to be 70 and therefore you might get WA.

So in short to correct your code you can just run for j from 0 to 9