結果
| 問題 |
No.1011 Infinite Stairs
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-29 12:34:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 347 ms / 2,000 ms |
| コード長 | 724 bytes |
| コンパイル時間 | 1,631 ms |
| コンパイル使用メモリ | 171,184 KB |
| 実行使用メモリ | 109,568 KB |
| 最終ジャッジ日時 | 2024-07-17 12:04:14 |
| 合計ジャッジ時間 | 3,777 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;
int main() {
int n,d,k;
cin >> n >> d >> k;
vector<vector<int>> dp(n+1,vector<int>(k+1));
dp[0][0] = 1;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
if(j > 0 && j-d-1 >= 0) dp[i][j] = ((dp[i-1][j-1] + dp[i][j-1])%MOD - dp[i-1][j-d-1] + MOD)%MOD;
else if(j > 0) dp[i][j] = (dp[i-1][j-1] + dp[i][j-1])%MOD;
else dp[i][j] = 0;
}
}
cout << dp[n][k] << endl;
return 0;
}