結果

問題 No.269 見栄っ張りの募金活動
コンテスト
ユーザー koba-e964
提出日時 2015-09-04 20:27:14
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 624 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 323 ms
コンパイル使用メモリ 71,532 KB
実行使用メモリ 19,384 KB
最終ジャッジ日時 2026-03-30 16:54:31
合計ジャッジ時間 1,751 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;


const ll mod = 1e9 + 7;

const int N = 101;
const int S = 20010;
ll dp[N][S];



int main(void){
  int n,s,k;
  cin >> n >> s >> k;
  int r = s - k * n * (n - 1) / 2;
  if (r < 0) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, 0, S) {
    dp[0][i] = 0;
  }
  dp[0][0] = 1;

  REP(i, 0, n) {
    REP(j, 0, S) {
      int w = i + 1;
      ll sub = dp[i][j];
      if (j >= w) {
	sub += dp[i + 1][j - w];
      }
      sub %= mod;
      dp[i + 1][j] = sub;
    }
  }
  cout << dp[n][r] << endl;
}
0