結果

問題 No.269 見栄っ張りの募金活動
ユーザー ishizuishizu
提出日時 2015-08-21 23:26:48
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 1,211 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 69,912 KB
実行使用メモリ 19,004 KB
最終ジャッジ日時 2024-07-16 01:30:01
合計ジャッジ時間 1,360 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>

#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<30
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define ll long long
#define ull unsigned long long
const ll MOD=1e9+7;

ll mpow(ll r,ll n, ll m){
    if(n==0) return 1;
    if(n==1) return r;
    ll res=mpow(r,n/2,m);
    res=(res*res)%m;
    if(n&1) res=(res*r)%m;
    return res;
}
ll m_inv(ll r,ll m){
    return mpow(r,m-2,m);
}

ll nck(ll n,ll k){
	ll a=1,b=1;
	REP(i,k){
		(a*=n-i)%=MOD;
		(b*=i+1)&=MOD;
	}
	return a*m_inv(b,MOD)%MOD;
}
ll dp[101][20010];
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,s,k;cin>>n>>s>>k;
	s -= (n-1)*n/2*k;
	if(s<0){ cout<<0<<endl; return 0;}
	dp[0][0]=1;
	FOR(i,1,n+1){
		FOR(j,0,s+1){
			if(j-i>=0) dp[i][j]=(dp[i-1][j]+dp[i][j-i])%MOD;
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][s]<<endl;
	 

}
0