結果
問題 | No.1011 Infinite Stairs |
ユーザー | pureforeverearth |
提出日時 | 2020-04-07 21:39:09 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 1,693 bytes |
コンパイル時間 | 1,476 ms |
コンパイル使用メモリ | 165,656 KB |
実行使用メモリ | 215,636 KB |
最終ジャッジ日時 | 2023-09-24 11:12:10 |
合計ジャッジ時間 | 2,937 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 3 ms
6,192 KB |
testcase_03 | AC | 78 ms
142,460 KB |
testcase_04 | AC | 17 ms
27,128 KB |
testcase_05 | AC | 117 ms
215,636 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 3 ms
4,968 KB |
testcase_08 | AC | 2 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,376 KB |
testcase_10 | AC | 2 ms
4,428 KB |
testcase_11 | AC | 20 ms
31,852 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 12 ms
20,788 KB |
testcase_14 | AC | 2 ms
4,380 KB |
testcase_15 | AC | 15 ms
26,008 KB |
testcase_16 | AC | 57 ms
100,948 KB |
testcase_17 | AC | 8 ms
11,528 KB |
testcase_18 | AC | 33 ms
59,392 KB |
testcase_19 | AC | 2 ms
4,376 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 15 ms
26,192 KB |
testcase_22 | AC | 29 ms
49,492 KB |
testcase_23 | AC | 17 ms
30,992 KB |
testcase_24 | AC | 18 ms
33,188 KB |
testcase_25 | AC | 30 ms
52,132 KB |
testcase_26 | AC | 8 ms
13,532 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0; i<n; i++) #define PI 3.14159265359 using namespace std; typedef long long ll; // auto mod int // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division const int mod = 1000000007; struct mint { ll x; // typedef long long ll; mint(ll x=0):x((x%mod+mod)%mod){} 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) 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 pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime mod mint inv() const { return pow(mod-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; // 出力は.xで!!!! int main(){ int n,d,k; cin >> n >> d >> k; mint dp[n+1][k+1]; mint rui[k+1]; rep(i,k+1) dp[0][i]=0; dp[0][0]=1; for(int i=1; i<=n; i++){ rui[0]=dp[i-1][0]; rep(p,k) rui[p+1]=rui[p]+dp[i-1][p+1]; for(int j=i; j<=min(k,(i+1)*d); j++){ if(j-d-1<0) dp[i][j]=rui[j-1]; else dp[i][j]=rui[j-1]-rui[j-d-1]; } } cout << dp[n][k].x << endl; return 0; }