結果

問題 No.287 場合の数
ユーザー m_tsubasam_tsubasa
提出日時 2020-07-29 17:55:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 1,046 bytes
コンパイル時間 2,495 ms
コンパイル使用メモリ 214,244 KB
実行使用メモリ 8,324 KB
最終ジャッジ日時 2023-09-12 01:14:13
合計ジャッジ時間 4,347 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
6,540 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 14 ms
8,324 KB
testcase_04 AC 14 ms
8,000 KB
testcase_05 AC 10 ms
6,628 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 5 ms
4,744 KB
testcase_08 AC 7 ms
5,612 KB
testcase_09 AC 9 ms
6,740 KB
testcase_10 AC 14 ms
8,180 KB
testcase_11 AC 4 ms
4,432 KB
testcase_12 AC 12 ms
7,580 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 6 ms
5,044 KB
testcase_15 AC 10 ms
6,592 KB
testcase_16 AC 6 ms
5,128 KB
testcase_17 AC 12 ms
7,208 KB
testcase_18 AC 5 ms
4,812 KB
testcase_19 AC 11 ms
7,100 KB
testcase_20 AC 6 ms
5,440 KB
testcase_21 AC 9 ms
6,816 KB
testcase_22 AC 10 ms
6,516 KB
testcase_23 AC 9 ms
5,980 KB
testcase_24 AC 5 ms
4,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long n;
vector<vector<long long>> com;
vector<vector<long long>> sum;
vector<vector<vector<long long>>> dp;

long long solve();

int main() {
  cin >> n;
  cout << solve() << endl;
  return 0;
}

long long solve() {
  com.resize(9);
  com[0].push_back(1);
  for (int i = 1; i <= 8; ++i) {
    com[i].assign(i + 1, 0);
    for (int j = 0; j < i; ++j) {
      com[i][j] += com[i - 1][j];
      com[i][j + 1] += com[i - 1][j];
    }
  }
  sum.assign(9, vector<long long>(6 * n + 1, 0));
  dp.assign(9, vector(6 * n + 1, vector<long long>(n + 1, 0)));
  dp[0][0][0] = sum[0][0] = 1;
  for (int k = 0; k <= n; ++k) {
    for (int i = 1; i <= 8; ++i)
      for (int j = 0; j <= 6 * n; ++j) {
        int len = i;
        if (k != 0) len = min(len, j / k);
        for (int l = 1; l <= len; ++l)
          dp[i][j][k] += sum[i - l][j - k * l] * com[8 - (i - l)][l];
      }
    for (int i = 1; i <= 8; ++i)
      for (int j = 0; j <= 6 * n; ++j) sum[i][j] += dp[i][j][k];
  }
  return sum[8][6 * n];
}
0