結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2019-08-18 00:44:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 5,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 1,592 ms |
コンパイル使用メモリ | 173,116 KB |
実行使用メモリ | 21,248 KB |
最終ジャッジ日時 | 2024-09-25 10:37:30 |
合計ジャッジ時間 | 2,490 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, n) for (ll i = 0; i < n; i++) #define FOR(i, a, b) for (ll i = a; i < b; i++) #define len(v) ll(v.size()) #define fi first #define se second template <class T> void cout_vec(const vector<T> &vec){ for(auto itr:vec) cout<<itr<<' '; cout<<endl; } typedef pair<ll,ll> P; const ll mod=1e9+7; const ll inf=1e15; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n,s,k; cin>>n>>s>>k; if(s-k*n*(n-1)/2<0){ cout<<0<<endl; return 0; } vector<vector<ll>> dp(s+10,vector<ll>(n+10,0)); dp[0][0]=1; rep(i,s+1)FOR(j,1,n+1){ if(i>=j) dp[i][j]=(dp[i-j][j]+dp[i][j-1])%mod; else dp[i][j]=dp[i][j-1]; } cout<<dp[s-k*n*(n-1)/2][n]<<endl; }