### arnthorla's blog

By arnthorla, history, 7 weeks ago,

I'm really stumped as to why my program outputs '3' on the test server but '4' on my computer.

I even tried to hardcode my solution to output '4' when it encounterd the test case, and that worked. But then interestingly I encounterd a very similar wrong answer in the 3rd batch of tests where my program output '4' but should have output '3'.

I find it kind of strange that in both cases it involves '3' and '4'.

This is my most recent submission: https://codeforces.com/contest/1485/submission/167766068

I'm compiling using: g++ -std=++17 -Wall

Thank you for any suggestions or ideas.

• +2

 » 7 weeks ago, # |   +3 Please those who are downvoting this, tell me why. Ok? Because I normally dont post like this.
•  » » 7 weeks ago, # ^ |   0 put the initial value of best and lim and tmp equal to 0.
•  » » » 7 weeks ago, # ^ | ← Rev. 2 →   +3 @hunter_of_alts: Thanks for the advice still the same result. Last submission (after change): https://codeforces.com/contest/1485/submission/167772884
•  » » » » 7 weeks ago, # ^ | ← Rev. 2 →   0 submit it with C++20, Also float or double multiplication and division is inaccurate and I think that's the reason why it gets WA.
•  » » » » » 7 weeks ago, # ^ | ← Rev. 2 →   +3 @hunter_of_alts: Hey that worked! :) Now I just get the other wrong answer, which is then due to some other cause. Any idea or best practices to avoid this issue in the future? And why are folks downvoting this? I know this is not fun stuff and I'm a noob. But but it is not like I haven't tried to solve this or worked on the error. I just did not see any good way of debugging this. Thanks a bunch!Edit: About the float/double issue. Yes, that might be the case. I just wanted to save calc by using logarithm. Perhaps I should try a larger base than 2. Perhaps base 10.
•  » » » » » » 7 weeks ago, # ^ | ← Rev. 2 →   0 Don't care about downvotes, The community likes to downvote for no reason, Also when you reply someone he/she will be mentioned on the ring above on top of the page, Also If you want to mention someone you have to write [user : someperson] without quotes, Also instead of using log10 or log2 or other math double operations of C++, Try to write them yourself, cuz it's safer and helps you to find your bugs fast, And are you the person in your profile?
•  » » » » » » » 7 weeks ago, # ^ | ← Rev. 2 →   0 Thanks hunter_of_alts. Yes, I revised my solution and now only use floor(log(a)/log(b))+1 to test for upper limit of operations. As a solution should be better than that. But normally I avoid using floats and doubles like the plague. ;)Yes, I am the guy on the photo. Edit: Here is the final version that was finally(!) accepted. :) https://codeforces.com/contest/1485/submission/167779370