結果

問題 No.269 見栄っ張りの募金活動
ユーザー oxyshoweroxyshower
提出日時 2019-07-03 20:57:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 165,108 KB
実行使用メモリ 19,140 KB
最終ジャッジ日時 2023-10-14 12:45:37
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 20 ms
18,020 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 15 ms
19,132 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 15 ms
15,568 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 10 ms
10,284 KB
testcase_14 AC 18 ms
19,140 KB
testcase_15 AC 11 ms
11,988 KB
testcase_16 AC 1 ms
4,352 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 8 ms
11,504 KB
testcase_19 AC 7 ms
7,976 KB
testcase_20 AC 7 ms
8,764 KB
testcase_21 AC 15 ms
16,656 KB
testcase_22 AC 6 ms
7,468 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 10 ms
12,080 KB
権限があれば一括ダウンロードができます

ソースコード

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