結果

問題 No.269 見栄っ張りの募金活動
ユーザー latte0119
提出日時 2015-10-31 19:10:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,431 ms / 5,000 ms
コード長 845 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 60,268 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-07-16 01:50:22
合計ジャッジ時間 5,546 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<cassert>
#include<cstring>
using namespace std;
typedef pair<int,int>pint;
typedef vector<int>vint;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

const int mod=1000000007;

int dp[101][20001];

int N,S,K;

int main(){
    cin>>N>>S>>K;
    if(K*(N-1)*N/2>S){
        cout<<0<<endl;
        return 0;
    }
    S-=K*(N-1)*N/2;

    dp[0][0]=1;

    rep(i,N){
        int r=N-i;
        rep(j,S+1){
            if(dp[i][j]==0)continue;
            for(int k=0;j+k*r<=S;k++){
                dp[i+1][j+k*r]=(dp[i+1][j+k*r]+dp[i][j])%mod;
            }
        }
    }

    cout<<dp[N][S]<<endl;
    return 0;
}
0