結果

問題 No.269 見栄っ張りの募金活動
ユーザー Goi_dudeGoi_dude
提出日時 2020-03-08 20:16:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 1,062 bytes
コンパイル時間 1,359 ms
コンパイル使用メモリ 158,336 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-25 06:13:36
合計ジャッジ時間 2,576 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,136 KB
testcase_01 AC 6 ms
11,216 KB
testcase_02 AC 5 ms
11,264 KB
testcase_03 AC 5 ms
11,264 KB
testcase_04 AC 17 ms
12,352 KB
testcase_05 AC 6 ms
11,264 KB
testcase_06 AC 6 ms
11,264 KB
testcase_07 AC 37 ms
12,544 KB
testcase_08 AC 5 ms
11,252 KB
testcase_09 AC 5 ms
11,264 KB
testcase_10 AC 5 ms
11,264 KB
testcase_11 AC 8 ms
12,032 KB
testcase_12 AC 5 ms
11,380 KB
testcase_13 AC 9 ms
11,776 KB
testcase_14 AC 6 ms
12,500 KB
testcase_15 AC 8 ms
11,904 KB
testcase_16 AC 5 ms
11,264 KB
testcase_17 AC 4 ms
11,176 KB
testcase_18 AC 16 ms
11,832 KB
testcase_19 AC 8 ms
11,620 KB
testcase_20 AC 5 ms
11,648 KB
testcase_21 AC 8 ms
12,160 KB
testcase_22 AC 7 ms
11,520 KB
testcase_23 AC 5 ms
11,264 KB
testcase_24 AC 6 ms
11,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int dp[101][20002];

int f(int n,int s){
    // K = 0 のとき n人でsを分ける方法 
    if(n == 0 && s == 0)return 1;
    if(n<=0 || s<0)return 0;
    if(dp[n][s]!=-1)return dp[n][s];

    dp[n][s] = f(n-1,s) % mod + f(n,s-n) % mod;
    return dp[n][s] % mod;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    rep(i,101)rep(j,20002)dp[i][j] = -1;
    int N,S,K;
    cin >> N >> S >> K;
    S -= K*N*(N-1)/2;
    cout << f(N,S) % mod << endl;
}
0