Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Reputeless committed Dec 21, 2021
1 parent c5b7281 commit e7b0ac7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
48 changes: 48 additions & 0 deletions 050.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# 050 - Stair Jump (★3)

## 解答

```cpp
#include <iostream>
#include <vector>

int main()
{
// N 段の階段, 一歩で 1 段か L 段上る
int N, L;
std::cin >> N >> L;

// 0 段目から N 段目までの通り数を記録
std::vector<int> dp(N + 1);

// 0 段目では 1 通り
dp[0] = 1;

// i 段目 (i が 1~(L-1)) のときは
// (i-1) 段目までの通り数
for (int i = 1; i < L; ++i)
{
dp[i] = dp[i - 1];
}

// i 段目 (i が L~N) のときは
// (i-1) 段目までの通り数 + (i-L) 段目までの通り数
for (int i = L; i < (N + 1); ++i)
{
dp[i] = (dp[i - 1] + dp[i - L]) % 1'000'000'007;
}

// 例: N = 5, L = 3 のとき
// ___
// ___|[4]
// ___|[3] +
// ___|[2] + [2]
// ___|[1] + [1]
// ___|[0] [0]
// = 1 = 1 = 1 = 2 = 3 = 4
// [0] [1] [2] [3] [4] [5]

// 最終段までの通り数を出力
std::cout << dp.back() << '\n';
}
```
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ C++17 標準ライブラリの機能を優先して使い、競技プログラ
|[044](https://atcoder.jp/contests/typical90/tasks/typical90_ar)|[Shift and Swapping](./044.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/044.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/044.cpp)|見かけ上の変化をメモ|
|[046](https://atcoder.jp/contests/typical90/tasks/typical90_at)|[I Love 46](./046.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/046.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/046.cpp)|同じ意味のものをまとめて考える|
|[048](https://atcoder.jp/contests/typical90/tasks/typical90_av)|[I will not drop out](./048.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/048.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/048.cpp)|上界と下界を見積もる|
|050| | | | |
|[050](https://atcoder.jp/contests/typical90/tasks/typical90_ax)|[Stair Jump](./050.md)|★3|[👨‍🏫](https://raw.githubusercontent.com/E869120/kyopro_educational_90/main/editorial/050.jpg) / [📝](https://github.com/E869120/kyopro_educational_90/blob/main/sol/050.cpp)|漸化式を立てて DP をしよう|
|052| | | | |
|064| | | | |
|069| | | | |
Expand Down

0 comments on commit e7b0ac7

Please sign in to comment.