結果
問題 | No.2846 Birthday Cake |
ユーザー | shobonvip |
提出日時 | 2024-08-23 21:53:15 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 530 ms / 2,000 ms |
コード長 | 2,121 bytes |
コンパイル時間 | 2,613 ms |
コンパイル使用メモリ | 217,640 KB |
実行使用メモリ | 30,208 KB |
最終ジャッジ日時 | 2024-08-23 21:53:21 |
合計ジャッジ時間 | 5,320 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 14 ms
6,944 KB |
testcase_15 | AC | 530 ms
30,080 KB |
testcase_16 | AC | 2 ms
6,944 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | AC | 2 ms
6,940 KB |
testcase_20 | AC | 2 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 2 ms
6,940 KB |
testcase_23 | AC | 2 ms
6,940 KB |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | AC | 2 ms
6,940 KB |
testcase_26 | AC | 51 ms
7,424 KB |
testcase_27 | AC | 121 ms
11,520 KB |
testcase_28 | AC | 2 ms
6,940 KB |
testcase_29 | AC | 499 ms
30,208 KB |
testcase_30 | AC | 50 ms
7,424 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 2 ms
6,944 KB |
testcase_34 | AC | 2 ms
6,940 KB |
testcase_35 | AC | 2 ms
6,944 KB |
testcase_36 | AC | 2 ms
6,944 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; //#include<atcoder/all> //using namespace atcoder; //typedef modint998244353 mint; typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int k, n; cin >> k >> n; if (n <= 17){ vector<ll> mxg(n+1, 1); rep(i,0,n) mxg[i+1] = mxg[i]/__gcd(mxg[i], (ll)(i+1))*(i+1); vector<ll> v(n+1, 0); rep(i,1,n+1) v[i] = mxg[n]/i; vector<map<ll,ll>> a(n+1); a[0][0]=1; rep(i,0,n){ for(auto[j,c]:a[i]){ rrep(x,1,n+1){ if(j+v[x]>mxg[n])break; a[i+1][j+v[x]]+=c; } } } cout << a[k][mxg[n]] << endl; }else{ vector<vector<ll>> tar; tar.resize(25); tar[18] = {0,1,1,10,143,1321,12612,98967,706351,4519408,23098446,90446137,233499344,359830680,303875573,120897041,15574653,61864,1,}; tar[19] = {0,1,1,10,143,1321,12612,98967,706351,4519408,23098446,90446137,233499344,359830680,303875573,120897041,15574653,61864,1,1,}; tar[20] = {0,1,1,10,167,1851,20562,188049,1637057,12442024,81943326,429039909,1740647525,5233214351,10843887965,14088489255,9982510305,2962502213,198795808,582085,1,}; tar[21] = {0,1,1,10,167,2001,23622,247899,2492121,23603800,200197566,1457497196,8592067529,39580212205,134817405451,309930637885,426337329317,295288749243,73152855670,6996250795,28282071,1,}; tar[22] = {0,1,1,10,167,2001,23622,247941,2492905,23625220,200631786,1464757108,8683726163,40413510762,140147181266,332462625610,484295650621,382283766495,146218113382,38473778130,5684671181,173183578,1,}; tar[23] = {0,1,1,10,167,2001,23622,247941,2492905,23625220,200631786,1464757108,8683726163,40413510762,140147181266,332462625610,484295650621,382283766495,146218113382,38473778130,5684671181,173183578,1,1}; tar[24] = {0,1,1,10,191,2511,33882,409165,4641625,50103058,496822401,4403064282,33370486316,209225931487,1051662957619,4048971290390,11244715040211,20694326612398,22228226842243,11390082915896,2186175253228,151220665303,2381965422,1643558,1,}; cout << tar[n][k] << endl; } }