結果
問題 | No.1011 Infinite Stairs |
ユーザー | oevl |
提出日時 | 2020-04-19 11:55:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 3,463 bytes |
コンパイル時間 | 1,908 ms |
コンパイル使用メモリ | 203,016 KB |
実行使用メモリ | 215,636 KB |
最終ジャッジ日時 | 2023-09-24 11:12:48 |
合計ジャッジ時間 | 6,716 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 5 ms
6,584 KB |
testcase_01 | AC | 8 ms
8,668 KB |
testcase_02 | AC | 227 ms
184,776 KB |
testcase_03 | AC | 257 ms
205,052 KB |
testcase_04 | AC | 274 ms
215,636 KB |
testcase_05 | AC | 270 ms
215,480 KB |
testcase_06 | AC | 3 ms
5,192 KB |
testcase_07 | AC | 145 ms
116,296 KB |
testcase_08 | AC | 4 ms
5,092 KB |
testcase_09 | AC | 6 ms
7,196 KB |
testcase_10 | AC | 65 ms
53,768 KB |
testcase_11 | AC | 244 ms
193,916 KB |
testcase_12 | AC | 65 ms
52,936 KB |
testcase_13 | AC | 132 ms
105,736 KB |
testcase_14 | AC | 84 ms
67,672 KB |
testcase_15 | AC | 197 ms
156,464 KB |
testcase_16 | AC | 243 ms
192,432 KB |
testcase_17 | AC | 256 ms
203,632 KB |
testcase_18 | AC | 191 ms
149,596 KB |
testcase_19 | AC | 50 ms
41,164 KB |
testcase_20 | AC | 49 ms
40,140 KB |
testcase_21 | AC | 124 ms
97,392 KB |
testcase_22 | AC | 219 ms
171,880 KB |
testcase_23 | AC | 112 ms
88,296 KB |
testcase_24 | AC | 147 ms
116,336 KB |
testcase_25 | AC | 220 ms
173,328 KB |
testcase_26 | AC | 86 ms
68,448 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; template<int64_t MOD> class ModInt { public: int64_t x; constexpr ModInt() : x(0) {} constexpr ModInt(int64_t v) : x((v % MOD + MOD) % MOD) {} constexpr ModInt operator - () const noexcept { return x ? MOD - x : 0;} constexpr ModInt operator + (const ModInt a) const noexcept { return ModInt(*this) += a;} constexpr ModInt operator - (const ModInt a) const noexcept { return ModInt(*this) -= a;} constexpr ModInt operator * (const ModInt a) const noexcept { return ModInt(*this) *= a;} constexpr ModInt operator / (const ModInt a) const noexcept { return ModInt(*this) /= a;} constexpr ModInt operator / (const int64_t a) const noexcept { return ModInt(*this) /= a;} constexpr ModInt operator += (const ModInt a) noexcept { x += a.x; if (x >= MOD) x -= MOD; return *this; } constexpr ModInt operator += (const int64_t a) noexcept { auto hs = ModInt<MOD>(a); (*this) += hs; return *this; } constexpr ModInt operator -= (const ModInt a) noexcept { if (x < a.x) x += MOD; x -= a.x; return *this; } constexpr ModInt operator -= (const int64_t a) noexcept { auto hs = ModInt<MOD>(a); (*this) -= hs; return *this; } constexpr ModInt operator *= (const ModInt a) noexcept { x = x * a.x % MOD; return *this; } constexpr ModInt operator *= (const int64_t a) noexcept { auto hs = ModInt<MOD>(a); (*this) *= hs; return *this; } constexpr ModInt &operator /= (ModInt a) noexcept { int64_t exp = MOD - 2; while (exp > 0) { if (exp & 1ul) *this *= a; a *= a; exp >>= 1ul; } return *this; } constexpr ModInt &operator /= (int64_t a) noexcept { auto hs = ModInt<MOD>(a); (*this) /= hs; return *this; } constexpr ModInt &operator ++ () noexcept { if (++x >= MOD) x -= MOD; return *this; } constexpr ModInt &operator -- () noexcept { if (x-- == 0) x += MOD; return *this; } constexpr bool operator < (const ModInt a) const noexcept { return x < a.x;} constexpr bool operator == (const ModInt a) const noexcept { return this->x == a.x;} constexpr bool operator != (const ModInt a) const noexcept { return !(*this == a);} friend istream &operator >> (istream &in, ModInt &m) { in >> m.x; if (m.x < 0) m.x += MOD; m.x %= MOD; return in; } friend ostream &operator << (ostream &out, const ModInt &p) { return out << p.x;} constexpr ModInt pow(int64_t p) const { ModInt ret(1); ModInt mul(x); while (p > 0) { if (p & 1ul) ret *= mul; mul *= mul; p >>= 1ul; } return ret; } }; const int64_t MOD = 1000000007LL; using mint = ModInt<MOD>; int main() { int N, d, K; cin >> N >> d >> K; const int M = 90009; vector<vector<mint>> dp(N + 1, vector<mint>(M + 2)); dp[0][0] = 1; for(int i = 1; i <= N; ++i) { for(int j = 0; j < M; ++j) dp[i - 1][j + 1] += dp[i - 1][j]; for(int j = 1; j <= M; ++j) { if(j - d - 1 < 0) dp[i][j] = dp[i - 1][j - 1]; else dp[i][j] = dp[i - 1][j - 1] - dp[i - 1][j - d - 1]; } } cout << dp[N][K] << '\n'; return 0; }