結果

問題 No.269 見栄っ張りの募金活動
ユーザー atudn
提出日時 2022-11-05 17:26:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 1,182 bytes
コンパイル時間 1,944 ms
コンパイル使用メモリ 170,964 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-07-19 09:45:01
合計ジャッジ時間 2,660 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,a,n) for(int i=(int)a;i<(int)n;++i)
#define fi first
#define se second
#define PI 3.14159265359
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
using veci=vector<int>;
using vecii=vector<pair<int,int>>;
using vecll=vector<long long>;
using vecpll=vector<pair<long long,long long>>;
using vecs=vector<string>;
using vecb=vector<bool>;
using vecd=vector<double>;
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;}
 
constexpr int INF=1<<30;
//constexpr ll INF=1LL<<61;
//constexpr int MOD=1000000007;
constexpr ll MOD=1000000007;
//constexpr ll MOD=998244353;
//constexpr int LOG=62;


int main(){
	//ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());
	
	ll n,s,k;cin>>n>>s>>k;
	s-=n*(n-1)*k/2;
	if(s<0) {
		cout<<0<<endl;
		return 0;
	}
	vector<vecll> dp(s+1,vecll(n+1,0));
	rep(i,n+1) dp[0][i]=1;
	rep1(i,1,s+1) rep1(j,1,n+1){
		dp[i][j]=dp[i][j-1]+(i>=j?dp[i-j][j]:0);
		dp[i][j]%=MOD;
	}
	cout<<dp[s][n]<<endl;
}
0