結果

問題 No.269 見栄っ張りの募金活動
ユーザー legosuke
提出日時 2018-03-09 22:06:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 158,116 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-16 02:03:04
合計ジャッジ時間 1,975 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int mod = 1e9 + 7;
int N, S, K;
int dp[101][20010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> S >> K;
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= S; j++) {
      dp[i][j] = dp[i - 1][j];
      if (j - i >= 0) {
        (dp[i][j] += dp[i][j - i]) %= mod;
      }
    }
  }
  
  int sum = S - K * N * (N - 1) / 2;
  cout << (sum < 0 ? 0 : dp[N][sum]) << endl;

  return 0;
}
0