結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
naribow
|
| 提出日時 | 2020-08-11 18:06:01 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 997 bytes |
| コンパイル時間 | 1,680 ms |
| コンパイル使用メモリ | 170,252 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-10-09 11:36:03 |
| 合計ジャッジ時間 | 2,701 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
int N, S, K, mod = 1e9+7;
cin >> N >> S >> K;
if(N * (N-1) / 2 * K > S) {
cout << 0 << endl;
return 0;
}
int M = N;
N = S - K * (N-1) * N / 2;
vector<vector<int> > dp(M+1, vector<int>(N+1));
dp[0][0] = 1;
rep2(i, 1, M+1){
rep(j, N+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[M][N] << endl;
}
naribow