結果

問題 No.1011 Infinite Stairs
ユーザー 👑 zeronosu77108zeronosu77108
提出日時 2020-03-21 00:27:37
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 1,882 bytes
コンパイル時間 3,591 ms
コンパイル使用メモリ 84,548 KB
実行使用メモリ 216,876 KB
最終ジャッジ日時 2023-09-24 11:03:45
合計ジャッジ時間 2,703 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 6 ms
6,072 KB
testcase_03 AC 172 ms
143,308 KB
testcase_04 AC 56 ms
27,400 KB
testcase_05 AC 262 ms
216,876 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 7 ms
4,952 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 42 ms
31,900 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 26 ms
20,816 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 28 ms
26,076 KB
testcase_16 AC 131 ms
102,128 KB
testcase_17 AC 34 ms
11,788 KB
testcase_18 AC 70 ms
59,576 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 32 ms
26,776 KB
testcase_22 AC 70 ms
50,140 KB
testcase_23 AC 36 ms
31,136 KB
testcase_24 AC 38 ms
33,488 KB
testcase_25 AC 62 ms
52,512 KB
testcase_26 AC 14 ms
13,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

using int64 = long long;

const int MOD = 1000000007;
struct mint {
    int64 x;
    mint(const int64 x1=0) { x = x1%MOD; };

    mint& operator++(int n) { x+=1; return *this; };
    mint& operator--(int n) { x-=1; return *this; };
    mint& operator=(int64 n) { x=n%MOD; return *this; };
    mint& operator--() {x-=1; return *this; };
    mint& operator+=(const mint a) { if ( (x+=a.x) >= MOD) x-=MOD; return *this; }
    mint& operator-=(const mint a) { if ( (x+= MOD-a.x) >= MOD) x-= MOD; return *this; }
    mint& operator*=(const mint a) { (x*=a.x) %= MOD; return *this; }
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
    mint inv() const { return pow(MOD-2);}
    friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
    constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
    constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
    mint pow(long long t) const {
        if (!t) return mint(1);
        mint a = pow(t>>1);
        a*=a;
        if(t&1) a*= *this;
        return a;
    }
};

int main() {
    int n, d, k;
    cin >> n >> d >> k;
    vector<vector<mint>> dp(n + 1, vector<mint>(k + d + 1, 0));
    dp[0][0] = 1;

    for (int i=0; i<n; i++) {
        for (int j=0; j<=d*n; j++) {
            if (j > k-1) continue;
            dp[i+1][j+1] += dp[i][j];
            dp[i+1][j+1+d] -= dp[i][j];
            dp[i+1][j+1] += dp[i+1][j];
        }
    }

    cout << dp[n][k] << endl;
}
0