結果

問題 No.269 見栄っ張りの募金活動
ユーザー simansiman
提出日時 2020-10-22 17:52:57
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 4,399 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 3,914 ms
コンパイル使用メモリ 139,764 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-07-21 09:25:09
合計ジャッジ時間 16,637 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int INF = INT_MAX;
int N, S, K;

const int MAX_N = 101;
const int MAX_S = 20010;
ll dp[MAX_N][MAX_S];

ll dfs(int n, int s) {
  if (s < 0) return 0;
  if (n == N - 1) return 1;
  if (dp[n][s] != -1) return dp[n][s];

  ll res = 0;

  for (int i = 0; i * (N - n) <= s; ++i) {
    res += dfs(n + 1, s - i * (N - n));
    res %= MOD;
  }

  return dp[n][s] = res;
}

int main() {
  cin >> N >> S >> K;
  S -= (N * (N - 1) / 2) * K;
  memset(dp, -1, sizeof(dp));

  cout << dfs(0, S) << endl;

  return 0;
}
0