結果

問題 No.1011 Infinite Stairs
ユーザー rnanornano
提出日時 2023-07-04 00:46:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 2,515 bytes
コンパイル時間 1,549 ms
コンパイル使用メモリ 165,788 KB
実行使用メモリ 269,956 KB
最終ジャッジ日時 2023-09-24 22:01:22
合計ジャッジ時間 5,009 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
269,836 KB
testcase_01 AC 71 ms
269,732 KB
testcase_02 AC 71 ms
269,780 KB
testcase_03 AC 95 ms
269,764 KB
testcase_04 AC 107 ms
269,772 KB
testcase_05 AC 107 ms
269,732 KB
testcase_06 AC 70 ms
269,768 KB
testcase_07 AC 75 ms
269,776 KB
testcase_08 AC 70 ms
269,768 KB
testcase_09 AC 70 ms
269,784 KB
testcase_10 AC 71 ms
269,824 KB
testcase_11 AC 85 ms
269,764 KB
testcase_12 AC 71 ms
269,840 KB
testcase_13 AC 79 ms
269,788 KB
testcase_14 AC 70 ms
269,868 KB
testcase_15 AC 76 ms
269,736 KB
testcase_16 AC 95 ms
269,772 KB
testcase_17 AC 96 ms
269,768 KB
testcase_18 AC 81 ms
269,776 KB
testcase_19 AC 71 ms
269,780 KB
testcase_20 AC 71 ms
269,776 KB
testcase_21 AC 76 ms
269,836 KB
testcase_22 AC 93 ms
269,956 KB
testcase_23 AC 76 ms
269,840 KB
testcase_24 AC 75 ms
269,728 KB
testcase_25 AC 80 ms
269,720 KB
testcase_26 AC 72 ms
269,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i,n) for (int i = (int)(n-1); i >= 0; --i)
#define Rep(i,a,b) for (int i = a; i < b; ++i)
#define rRep(i,a,b) for (int i = a; i > b; --i)
#define fore(i,a) for(auto &i:a)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define Unique(v) v.erase(unique(v.begin(), v.end()), v.end());
#define Bit(x,i) (((x)>>(i))&1)
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
struct settings{settings(){ios_base::sync_with_stdio(0); cin.tie(0); cout<<fixed<<setprecision(15);};}settingss;
const double PI = acos(-1);
const int INF = 1001001001;
const ll LINF = 1001001001001001001LL;

const int mod = 1000000007;
class modint {
  long long x;
public:
  modint(long long x=0) : x((x%mod+mod)%mod) {}
  modint operator-() const {
    return modint(-x);
  }
  modint& operator+=(const modint& a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  modint& operator-=(const modint& a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  modint& operator*=(const  modint& a) {
    (x *= a.x) %= mod;
    return *this;
  }
  modint operator+(const modint& a) const {
    modint res(*this);
    return res+=a;
  }
  modint operator-(const modint& a) const {
    modint res(*this);
    return res-=a;
  }
  modint operator*(const modint& a) const {
    modint res(*this);
    return res*=a;
  }
  modint pow(ll t) const {
    if (!t) return 1;
    modint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  modint inv() const {
    return pow(mod-2);
  }
  modint& operator/=(const modint& a) {
    return (*this) *= a.inv();
  }
  modint operator/(const modint& a) const {
    modint res(*this);
    return res/=a;
  }
  friend ostream& operator<<(ostream& os, const modint& m){
    os << m.x;
    return os;
  }
};

modint dp[310][110000];

int main() {
  ll N, d, K; cin >> N >> d >> K;
  dp[0][0] = 1;
  rep(i, N) {
    Rep(j, i, (i+1)*d + 1) {
      dp[i+1][j+1] += dp[i][j];
      dp[i+1][j+d+1] -= dp[i][j];
      dp[i+1][j+1] += dp[i+1][j];
    }
  }
  cout << dp[N][K] << endl;
}
0