結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, S, K;
  cin >> N >> S >> K;

  ll dp[S+1][N+1];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  ll mod = 1e9+7;

  for(int i=0;i<=S;i++) {
    for(int j=1;j<=N;j++) {
      dp[i][j] = dp[i][j-1];
      if(i-j >= 0)
        dp[i][j] += dp[i-j][j];
      dp[i][j] %= mod;
    }
  }

  ll x = S;
  for(int i=0;i<N;i++)
    x -= i*K;
  if(x < 0)
    cout << 0 << endl;
  else
    cout << dp[x][N] << endl;
}
0