結果
問題 |
No.1011 Infinite Stairs
|
ユーザー |
![]() |
提出日時 | 2020-04-29 12:21:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 2,000 ms |
コード長 | 644 bytes |
コンパイル時間 | 1,569 ms |
コンパイル使用メモリ | 168,752 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-17 12:06:04 |
合計ジャッジ時間 | 3,289 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; const ll MOD = 1e9 + 7; int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n, d, k; cin >> n >> d >> k; ll max_n = n * (d - 1) + 1; ll dp[2][max_n]; rep(i, 2) rep(j, max_n) dp[i][j] = 0; dp[0][0] = 1; rep(i, n){ ll t = 0; rep(j, (i+1) * (d - 1) + 1){ t += dp[i%2][j]; t %= MOD; if(j >= d) { t += MOD - dp[i%2][j-d]; t %= MOD; } dp[(i+1) % 2][j] = t; } } int idx = (k-1) - (n-1); if(idx < 0 || idx >= max_n){ cout << 0 << endl; }else{ cout << dp[n % 2][idx] << endl; } }