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

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

In this problem,I have come up with a solution that is only equal bit length numbers meet the condition of & operation >= XOR operation. That means number 2-3,4-7,8-15.... meet the conditions given in this problem.

Based on this idea, I write a solution, But this is giving always wrong answer. I am so frustrated and don't have a clue what is missing.

My code is

Can anybody please help me,what is wrong with my approach?

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

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

Have you tried the following:

  • Write a very naive and simple solution to the problem (maybe exponential complexity) (if you can, you may also just copy someone else's solution)
  • Write a program to generate thousands of small (!) test cases
  • Using those two, find a test case where your program gives the wrong answer
  • Use print statements or a debugger to see where exactly your program does the wrong thing.

98% of WAs and REs can be resolved this way. People here don't have the time to delve into every code posted here, it's much harder to debug somebody else's code and being able to debug your own code is a valuable skill. It is also a very routine process that can be learned much faster than problem solving and algorithms.

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

ans overflows