結果

問題 No.1011 Infinite Stairs
ユーザー shop_one
提出日時 2020-03-21 18:49:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 98,008 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-17 12:00:27
合計ジャッジ時間 4,798 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define MOD 1000000007
#define MAX 100000
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
vector<ll> dp(MAX,0);
signed main(){
  init_io();
  ll n,d,k;
  cin >> n >> d >> k;
  dp[0] = 1;
  for(int i=0;i<n;i++){
    for(int j=1;j<MAX;j++){
      dp[j] += dp[j-1];
      dp[j] %= MOD;
    }
  }
  for(int i=0;i<n;i++){
    vector<ll> cdp(dp.begin(),dp.end());
    for(int i=d;i<MAX;i++){
      cdp[i] = (cdp[i]-dp[i-d]+MOD)%MOD;
    }
    dp = cdp;
  }
  cout << dp[k-n]<<endl;
}
0