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

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

Hello to all,today I find a interesting problem on codeforces B. The least round way,when I submit my code I get wrong answer on test 3 but at my PC I have a correct solution on this test,what is the problem?can someone help me?Thanks.

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

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

Well, you are right, it also works on my computer. So...

I get these warnings though:

D:\Programmation\C++\test\main.cpp||In function 'int nr0(long long int)':|
D:\Programmation\C++\test\main.cpp|27|warning: operation on 'nr' may be undefined [-Wsequence-point]|
D:\Programmation\C++\test\main.cpp||In function 'int minn(long long int, long long int)':|
D:\Programmation\C++\test\main.cpp|48|warning: no return statement in function returning non-void [-Wreturn-type]|
||=== Build finished: 0 errors, 2 warnings (0 minutes, 0 seconds) ===|

So, basically you don't return anything in one of your functions (but I think it's OK since you never use its return value), but your nr=nr++ is completely undefined.

So... undefined means what it means, it doesn't always work.

Just replace nr=nr++ by simply nr++, and it'll work :D

And... don't do this again ;-)