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

Автор Shadek, 10 лет назад, По-английски

Defining proper state was the root challenge in this problem.

State can be defined by dp[a][isFulfilled]

a is current sum and isFulfilled is true/1 if we made at least one single step with length >= d.

Base Cases are:

      if(a == n && isFulfilled == 1)
      {
            return 1;
      }
     
      if(a == n && isFulfilled == 0)
      {
            return 0;
      }
      
      if(a>n)
        return 0;
  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится