結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
|
提出日時 | 2020-03-20 21:43:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 182 ms / 2,000 ms |
コード長 | 1,164 bytes |
コンパイル時間 | 1,132 ms |
コンパイル使用メモリ | 89,720 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 11:46:47 |
合計ジャッジ時間 | 2,754 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream> #include<string> #include<iomanip> #include<cmath> #include<vector> #include<algorithm> #include<utility> using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; // } ; } fio; signed main(){ cout<<fixed<<setprecision(10); int N, d, K; vector<vector<int>> dp; cin>>N>>d>>K; dp.resize(2, vector<int>(K+1)); dp[0][0] = 1; for(int i = 0; i < N; i++){ //cout<<i<<endl; vector<int> imos(K+2); for(int j = 0; j < K; j++){ //cout<<j<<endl; imos[j+1] += dp[i%2][j]; imos[min(j+d+1,K+1)] -= dp[i%2][j]; imos[min(j+d+1,K+1)] += MOD; imos[min(j+d+1,K+1)] %= MOD; // for(int k = 1; k <= d; k++){ // if(j+k <= K){ // dp[(i+1)%2][j+k] += dp[i%2][j]; // dp[(i+1)%2][j+k] %= MOD; // } // } } for(int j = 0; j <= K; j++){ imos[j+1] += imos[j]; imos[j] %= MOD; dp[i%2][j] = 0; dp[((i+1)%2)][j] += imos[j]; dp[((i+1)%2)][j] %= MOD; } } //cout<<"x"<<endl; cout<<dp[(N)%2][K]<<endl; return 0; }