結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2019-10-04 19:21:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 856 bytes |
コンパイル時間 | 1,565 ms |
コンパイル使用メモリ | 167,528 KB |
実行使用メモリ | 18,972 KB |
最終ジャッジ日時 | 2024-10-03 06:57:46 |
合計ジャッジ時間 | 2,089 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>#define REP(i,a,b) for (int i=(a);i<(b);++i)#define rep(i,n) REP(i,0,n)#define sz(x) (x).size()using namespace std;typedef long long ll;typedef pair<int,int> pii;typedef pair<ll,ll> pll;const int INF = 1e9;const ll LINF = 1LL<<60;const ll MOD = 1e9+7;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; }ll n,s,k,dp[101][20001];int main() {cin>>n>>s>>k;ll ks = 0;rep(i,n) ks += k*i;if (ks > s) {cout << 0 << '\n';return 0;}ll r = s-ks;dp[0][0] = 1;REP(i,1,n+1) {rep(j,r+1) {if (j-i >= 0) dp[i][j] = (dp[i][j-i]%MOD+dp[i-1][j]%MOD)%MOD;else dp[i][j] = dp[i-1][j]%MOD;}}cout << dp[n][r] << '\n';return 0;}