結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
![]() |
提出日時 | 2020-03-20 21:45:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 608 ms / 2,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 1,650 ms |
コンパイル使用メモリ | 172,700 KB |
実行使用メモリ | 217,680 KB |
最終ジャッジ日時 | 2024-07-17 11:47:32 |
合計ジャッジ時間 | 4,572 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long int; using ull = unsigned long long int; using P = pair<int, int>; using P3 = pair<double,P>; using PP = pair<P, P>; constexpr int INF = 1 << 30; constexpr ll MOD = ll(1e9)+7; int main(){ int N, D, K; cin >> N >> D >> K; vector<vector<ll> > dp(K+1, vector<ll>(N+1)); for(int i=0;i<=K;i++){ dp[i][0] = 1; } for(int j=0;j<N;j++){ for(int i=0;i<K;i++){ if(i < D){ dp[i+1][j+1] = (dp[i][j] + dp[i][j+1]) % MOD; }else{ dp[i+1][j+1] = (dp[i][j] - dp[i-D][j] + dp[i][j+1] + MOD) % MOD; } } } cout << (dp[K][N]-dp[K-1][N]+MOD)%MOD << endl; return 0; }