結果

問題 No.269 見栄っ張りの募金活動
ユーザー penguinshunya
提出日時 2019-07-22 13:56:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 535 bytes
コンパイル時間 1,541 ms
コンパイル使用メモリ 165,732 KB
実行使用メモリ 13,076 KB
最終ジャッジ日時 2024-06-23 18:36:10
合計ジャッジ時間 2,530 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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