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

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

Submission 1 in this code my solution accepts if i inititiate dp with -1; Submission 2 in this code my solution exceeds if i inititiate with dp=0 what makes the difference between the 2? i know if d>n dp=0 but i have covered that solution already so what further cases it counts uselessly,please help!! Problem Source

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

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

Auto comment: topic has been updated by Vesper_Lynd (previous revision, new revision, compare).

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

Stab in the dark, but what if value for some cell is actually a multiple of M? It will be stored as 0 and every time you will need it you will have to recalculate, because you have no way to say whether it was already calculated or not. But if you set "non-value" as -1 then the problem disappears since calculated value cannot be equal to -1, since it is always in the range [0, M-1].

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

If some dp[i][j] is divisible by mod (1e9+7) then it will be calculated multiple times.