結果

問題 No.269 見栄っ張りの募金活動
ユーザー penguinshunyapenguinshunya
提出日時 2019-07-22 13:56:40
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 1,363 ms
コンパイル使用メモリ 164,272 KB
実行使用メモリ 12,936 KB
最終ジャッジ日時 2023-09-05 23:17:13
合計ジャッジ時間 2,587 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,956 KB
testcase_01 AC 4 ms
11,936 KB
testcase_02 AC 4 ms
11,920 KB
testcase_03 AC 5 ms
11,952 KB
testcase_04 AC 12 ms
12,868 KB
testcase_05 AC 5 ms
11,932 KB
testcase_06 AC 5 ms
12,096 KB
testcase_07 AC 25 ms
12,936 KB
testcase_08 AC 4 ms
11,904 KB
testcase_09 AC 6 ms
11,936 KB
testcase_10 AC 5 ms
11,968 KB
testcase_11 AC 7 ms
12,840 KB
testcase_12 AC 5 ms
11,964 KB
testcase_13 AC 7 ms
12,508 KB
testcase_14 AC 6 ms
12,852 KB
testcase_15 AC 7 ms
12,448 KB
testcase_16 AC 6 ms
11,912 KB
testcase_17 AC 5 ms
11,904 KB
testcase_18 AC 14 ms
12,348 KB
testcase_19 AC 7 ms
12,192 KB
testcase_20 AC 5 ms
12,228 KB
testcase_21 AC 5 ms
12,680 KB
testcase_22 AC 6 ms
12,176 KB
testcase_23 AC 4 ms
11,988 KB
testcase_24 AC 6 ms
12,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

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

int dfs(int i, int t) {
  if (t > S) return 0;
  if (me[i][t] != -1) return me[i][t];
  if (i == N) {
    return me[i][t] = (t == S);
  }
  return (me[i][t] = dfs(i + 1, t + K * (N - i - 1)) + dfs(i, t + N - i)) %= mod;
}

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