Omega1's blog

By Omega1, history, 9 years ago, In English

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.

  • Vote: I like it
  • +13
  • Vote: I do not like it

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

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 ;-)