結果

問題 No.269 見栄っ張りの募金活動
ユーザー ei1333333ei1333333
提出日時 2023-11-30 22:17:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4,220 ms / 5,000 ms
コード長 591 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 201,268 KB
実行使用メモリ 11,492 KB
最終ジャッジ日時 2023-11-30 22:17:54
合計ジャッジ時間 17,408 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
11,492 KB
testcase_01 AC 5 ms
11,492 KB
testcase_02 AC 5 ms
11,492 KB
testcase_03 AC 20 ms
11,492 KB
testcase_04 AC 2,966 ms
11,492 KB
testcase_05 AC 11 ms
11,492 KB
testcase_06 AC 6 ms
11,492 KB
testcase_07 AC 4,220 ms
11,492 KB
testcase_08 AC 5 ms
11,492 KB
testcase_09 AC 20 ms
11,492 KB
testcase_10 AC 4 ms
11,492 KB
testcase_11 AC 1,389 ms
11,492 KB
testcase_12 AC 8 ms
11,492 KB
testcase_13 AC 617 ms
11,492 KB
testcase_14 AC 343 ms
11,492 KB
testcase_15 AC 857 ms
11,492 KB
testcase_16 AC 25 ms
11,492 KB
testcase_17 AC 5 ms
11,492 KB
testcase_18 AC 1,073 ms
11,492 KB
testcase_19 AC 322 ms
11,492 KB
testcase_20 AC 186 ms
11,492 KB
testcase_21 AC 569 ms
11,492 KB
testcase_22 AC 210 ms
11,492 KB
testcase_23 AC 9 ms
11,492 KB
testcase_24 AC 487 ms
11,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;


int N, S, K;
int dp[101][20001];

int rec(int idx, int rest) {
  if(idx == 0) return rest == 0;
  if(~dp[idx][rest]) return dp[idx][rest];
  int ret = 0;
  for(int v = K; v * idx <= rest; v++) {
    ret += rec(idx - 1, rest - v * idx);
    if(ret >= mod) ret -= mod;
  }
  return dp[idx][rest] = ret;
}

int main() {
  cin >> N >> S >> K;
  memset(dp, -1, sizeof(dp));
  int ret = 0;
  for(int i = 0; i * N <= S; i++) {
    (ret += rec(N - 1, S - i * N)) %= mod;
  }
  cout << ret << endl;
}
0