結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
![]() |
提出日時 | 2020-02-20 12:04:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 352 ms / 2,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 791 ms |
コンパイル使用メモリ | 75,684 KB |
実行使用メモリ | 215,820 KB |
最終ジャッジ日時 | 2024-07-17 11:43:16 |
合計ジャッジ時間 | 4,038 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<utility> #include<cassert> typedef long long ll; constexpr ll mod = 1e9+7; int main(){ ll N,K,d; std::cin>>N>>d>>K; assert(1<=N&&N<=300); assert(1<=d&&d<=300); assert(N<=K&&K<=N*d); std::vector<std::vector<ll>> dp(N+1,std::vector<ll>(N*d+1,0)); std::vector<ll> S(d*N+2,0); dp[0][0]=1; for(int i=0;i<N;++i){ for(int j=0;j<d*N+1;++j){ S[j+1] = (S[j] + dp[i][j])%mod; } for(int j=0;j<d*N+1;++j){ if(j<d) dp[i+1][j]=S[j]; else dp[i+1][j]=S[j]-S[j-d]+mod; dp[i+1][j]%=mod; } } std::cout<<dp[N][K]<<std::endl; }