結果

問題 No.269 見栄っ張りの募金活動
ユーザー nemakura3nemakura3
提出日時 2019-10-04 19:21:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 856 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 162,768 KB
実行使用メモリ 19,256 KB
最終ジャッジ日時 2024-04-14 09:59:24
合計ジャッジ時間 2,682 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 4 ms
11,884 KB
testcase_04 AC 6 ms
9,984 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 5 ms
18,000 KB
testcase_07 AC 15 ms
19,256 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 4 ms
7,912 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 4 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 7 ms
14,528 KB
testcase_19 AC 4 ms
8,352 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,948 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define sz(x) (x).size()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF = 1e9;
const ll LINF = 1LL<<60;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll n,s,k,dp[101][20001];

int main() {
  cin>>n>>s>>k;
  ll ks = 0;
  rep(i,n) ks += k*i;
  if (ks > s) {
    cout << 0 << '\n';
    return 0;
  }
  ll r = s-ks;
  dp[0][0] = 1;
  REP(i,1,n+1) {
    rep(j,r+1) {
      if (j-i >= 0) dp[i][j] = (dp[i][j-i]%MOD+dp[i-1][j]%MOD)%MOD;
      else dp[i][j] = dp[i-1][j]%MOD;
    }
  }
  cout << dp[n][r] << '\n';
  return 0;
}
0