結果

問題 No.1011 Infinite Stairs
ユーザー 0w1
提出日時 2020-11-15 14:56:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 194,188 KB
最終ジャッジ日時 2025-01-16 00:56:19
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, D, K; {
    cin >> N >> D >> K;
  }

  const int M = 1e9 + 7;

  vector<int> d(K + 1); {
    d[0] = 1;
    for (int i = 0; i < N; ++i) {
      vector<int> nd(K + 1); {
        int spd = d[0];
        for (int j = 1; j <= K; ++j) {
          if (j - D - 1 >= 0) (spd -= d[j - D - 1]) %= M;
          nd[j] = spd;
          (spd += d[j]) %= M;
        }
      }
      swap(d, nd);
    }
  }

  int res = d[K]; {
    if (res < 0) res += M;
  }

  cout << res << endl;
}
0