結果

問題 No.269 見栄っ張りの募金活動
ユーザー utan
提出日時 2021-04-27 02:41:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 938 bytes
コンパイル時間 1,436 ms
コンパイル使用メモリ 167,512 KB
実行使用メモリ 20,648 KB
最終ジャッジ日時 2024-07-05 18:32:27
合計ジャッジ時間 2,463 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


typedef long long ll;
ll MOD = 1000000007;

const ll INF = 1001001001001001001;
const int inf = 1001001001;
using P = pair<ll, ll>;

struct edge {
    int to, cost;
};

bool comp(P l, P r) {
    return ((l.first < r.first) || ((l.first == r.first) && (l.second > r.second)));
    
}

int main() {
    int N, S, K;cin>> N >> S >> K;
    if (S-N*(N -1)*K/2 < 0) {
        cout << 0 << endl;
        return 0;
    }
    ll dp[110][20011] = {0LL};
    for (int i = 0; i <= 20010; i++) {
        dp[1][i] = 1LL;

    }
    for (int i = 2; i <= N; i++) {
        for (int j = 0; j <= S-N*(N-1)*K/2; j++) {
            if (j >= i) {
                dp[i][j] = (dp[i][j-i]+dp[i-1][j])%MOD;
            } else {
                dp[i][j] = (dp[i-1][j])%MOD;
            }

        }
    }
    cout << dp[N][S-N*(N-1)*K/2]%MOD << endl;
    return 0;
}
    
    
        
        
        
    
    


0