結果

問題 No.269 見栄っ張りの募金活動
ユーザー sansaquasansaqua
提出日時 2019-08-07 04:48:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 1,547 bytes
コンパイル時間 724 ms
コンパイル使用メモリ 83,100 KB
実行使用メモリ 11,872 KB
最終ジャッジ日時 2023-09-25 22:31:43
合計ジャッジ時間 2,429 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
11,808 KB
testcase_01 AC 20 ms
11,840 KB
testcase_02 AC 20 ms
11,872 KB
testcase_03 AC 20 ms
11,760 KB
testcase_04 AC 20 ms
11,832 KB
testcase_05 AC 20 ms
11,828 KB
testcase_06 AC 20 ms
11,812 KB
testcase_07 AC 20 ms
11,832 KB
testcase_08 AC 21 ms
11,828 KB
testcase_09 AC 20 ms
11,480 KB
testcase_10 AC 19 ms
11,488 KB
testcase_11 AC 20 ms
11,484 KB
testcase_12 AC 20 ms
11,496 KB
testcase_13 AC 20 ms
11,772 KB
testcase_14 AC 20 ms
11,776 KB
testcase_15 AC 20 ms
11,760 KB
testcase_16 AC 20 ms
11,492 KB
testcase_17 AC 20 ms
11,760 KB
testcase_18 AC 21 ms
11,496 KB
testcase_19 AC 20 ms
11,828 KB
testcase_20 AC 20 ms
11,756 KB
testcase_21 AC 20 ms
11,800 KB
testcase_22 AC 20 ms
11,484 KB
testcase_23 AC 20 ms
11,840 KB
testcase_24 AC 20 ms
11,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <list>
#include <cassert>
#include <queue>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long int;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define YES(n) std::cout << ((n) ? "YES" : "NO"  ) << "\n";
#define Yes(n) std::cout << ((n) ? "Yes" : "No" ) << "\n";

#define ALL_INCLUDED_ENVIRONMENT

template <class T, class Alloc, template <class, class> class C> std::ostream& operator<<(std::ostream& o, const C<T, Alloc>& v) {
  o << "{";
  bool init = 1;
  for (auto e : v) {
    if (init) { init = 0; }
    else { o << ", "; }
    o << e;
  }
  o << "}";
  return o;
}

const int SUM_SUP = 20001;
const int PARTITION_SUP = 101;
const int MOD = 1000000007;
vector<vector<int> > partition_number(SUM_SUP, vector<int>(PARTITION_SUP, 0));

void build_partition_number() {
  for (int k = 0; k < PARTITION_SUP; k++) {
    partition_number[0][k] = 1;
  }
  for (int n = 1; n < SUM_SUP; n++) {
    for (int k = 1; k <= PARTITION_SUP; k++) {
      if (k > n) {
        partition_number[n][k] = partition_number[n][n];
      } else {
        partition_number[n][k] = (partition_number[n][k-1] + partition_number[n-k][k])%MOD;
      }
    }
  }
}

int main() {
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  ll n, s, k;
  cin >> n >> s >> k;
  build_partition_number();
  
  ll rest = s - n*(n-1)*k/2;
  ll ans;

  if (rest < 0)
    ans = 0;
  else {
    ans = partition_number[rest][n];
  }

  cout << ans << "\n";
  return 0;
}
0