結果

問題 No.269 見栄っ張りの募金活動
ユーザー koba-e964koba-e964
提出日時 2015-09-04 20:27:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 624 bytes
コンパイル時間 366 ms
コンパイル使用メモリ 52,644 KB
実行使用メモリ 19,260 KB
最終ジャッジ日時 2023-09-23 01:12:28
合計ジャッジ時間 1,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 7 ms
13,580 KB
testcase_04 AC 6 ms
9,812 KB
testcase_05 AC 4 ms
5,112 KB
testcase_06 AC 12 ms
19,260 KB
testcase_07 AC 11 ms
19,132 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
5,180 KB
testcase_11 AC 3 ms
5,076 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 5 ms
9,540 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
7,496 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 9 ms
15,732 KB
testcase_19 AC 6 ms
9,684 KB
testcase_20 AC 3 ms
4,448 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 5 ms
7,480 KB
testcase_23 AC 4 ms
7,448 KB
testcase_24 AC 3 ms
4,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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