ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1017. Staircases

Need help
Posted by ComebackSeason 8 Jul 2017 10:01
Could someone explain this idea?
tbl[0] = 1;
for (int i = 1; i <= N; i++)
{
    for (int j = N; j >= i ; j--)
    {
            tbl[j] += tbl[j-i];
    }
}
cout<<tbl[N]-1<<endl;
Re: Need help
Posted by Mahilewets 8 Jul 2017 16:20
It is compressed 2-dimensional dynamic programming state.
It is like we take staircase from 1,2,...,N cubes and add one more step.
Subtract one to not count zero len staircase.

Edited by author 08.07.2017 16:20

"Compressed " means that say dp[x] = Sum(dp[x] [i]) {i = 0,1,...,N}

Edited by author 08.07.2017 16:20

Edited by author 08.07.2017 16:22