結果

問題 No.269 見栄っ張りの募金活動
ユーザー oxyshower
提出日時 2019-07-03 20:57:45
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 165,836 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-09-16 07:34:42
合計ジャッジ時間 2,401 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

const int MOD = 1e9+7;

signed main(){

  int n,s,k; cin >> n >> s >> k;

  s -= n*(n-1)*k/2;
  if(s < 0){
    cout << 0 << endl;
    return 0;
  }
  static int dp[20001][101]; //iをj以下の自然数の和に分ける場合の数
  dp[0][0] = 1;
  for(int i = 0; i <= s; i++){
    for(int j = 1; j <= n; j++){
      if(i-j >= 0){
        dp[i][j] = dp[i-j][j] + dp[i][j-1];
      }
      else {
        dp[i][j] = dp[i][j-1];
      }
      dp[i][j] %= MOD;
    }
  }
  cout << dp[s][n] << endl;

  return 0;
}
0