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

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

A problems are simple, and I tried to submit once without testing, but I always failed to accept at once. Sometimes I get stuck in very simple mistakes. I feel that programming is so hard because of those mistakes, so I even don't have confidence to think about harder problems with advanced algorithm. Any advice please? Maybe I should change from C to another language? (But sometimes I really enjoy graspping the idea of hard problems. There are so many difficulties and exceptions for me to communicate with my computer.)

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

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +12 Проголосовать: не нравится

but I always failed to accept at once

That's because of inexperience. I used to get stupid bugs in the past. But after some practice, I got accustomed to the usual bugs that would occur in my code (like dividing by zero, integer overflow, off by one bugs, etc.). You just got to keep practicing. Spotting these trivial bugs will soon become second nature to you.

Anyway, (div 2) problem A usually don't have many corner cases (if any at all). The obvious things to look out for, though, would be extremely small input, extremely large input, empty sets, etc.

What I do though, is to read through my code once to see if it is intuitively correct. If it is clearly correct, I submit. Otherwise, I manually try a few cases. Worst case, if I am not confident of my solution, I would start writing a test case generator.