結果

問題 No.269 見栄っ張りの募金活動
ユーザー penguinshunyapenguinshunya
提出日時 2019-07-22 19:05:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 506 bytes
コンパイル時間 1,504 ms
コンパイル使用メモリ 164,212 KB
実行使用メモリ 12,840 KB
最終ジャッジ日時 2023-09-05 23:20:41
合計ジャッジ時間 2,848 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,160 KB
testcase_01 AC 5 ms
11,908 KB
testcase_02 AC 5 ms
11,896 KB
testcase_03 AC 6 ms
11,956 KB
testcase_04 AC 13 ms
12,684 KB
testcase_05 AC 5 ms
11,856 KB
testcase_06 AC 5 ms
11,856 KB
testcase_07 AC 27 ms
12,840 KB
testcase_08 AC 5 ms
11,828 KB
testcase_09 AC 6 ms
11,908 KB
testcase_10 AC 5 ms
11,920 KB
testcase_11 AC 7 ms
12,772 KB
testcase_12 AC 6 ms
11,900 KB
testcase_13 AC 8 ms
12,268 KB
testcase_14 AC 6 ms
12,828 KB
testcase_15 AC 7 ms
12,404 KB
testcase_16 AC 6 ms
11,916 KB
testcase_17 AC 5 ms
11,960 KB
testcase_18 AC 14 ms
12,548 KB
testcase_19 AC 7 ms
12,120 KB
testcase_20 AC 6 ms
12,124 KB
testcase_21 AC 6 ms
12,696 KB
testcase_22 AC 6 ms
12,340 KB
testcase_23 AC 5 ms
12,072 KB
testcase_24 AC 6 ms
12,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int N, S, K;
int dp[110][20010];

int dfs(int i, int k) {
  if (k > S) return 0;
  if (dp[i][k] != -1) return dp[i][k];
  if (i == N) {
    return dp[i][k] = (k == S);
  }
  int ret = dfs(i + 1, k + K * (N - i - 1)) + dfs(i, k + N - i);
  return dp[i][k] = ret % 1000000007;
}

int main() {
  cin >> N >> S >> K;
  for (int i = 0; i < 110; i++) {
    for (int j = 0; j < 20010; j++) {
      dp[i][j] = -1;
    }
  }
  cout << dfs(0, 0) << '\n';
  return 0;
}
0