結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2019-08-07 04:48:28 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 5,000 ms |
コード長 | 1,547 bytes |
コンパイル時間 | 914 ms |
コンパイル使用メモリ | 84,912 KB |
実行使用メモリ | 11,776 KB |
最終ジャッジ日時 | 2024-07-18 18:11:22 |
合計ジャッジ時間 | 2,197 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <utility>#include <set>#include <list>#include <cassert>#include <queue>#include <cmath>#include <algorithm>using namespace std;using ll = long long int;#define REP(i, n) for(int i = 0; i < (int)(n); i++)#define YES(n) std::cout << ((n) ? "YES" : "NO" ) << "\n";#define Yes(n) std::cout << ((n) ? "Yes" : "No" ) << "\n";#define ALL_INCLUDED_ENVIRONMENTtemplate <class T, class Alloc, template <class, class> class C> std::ostream& operator<<(std::ostream& o, const C<T, Alloc>& v) {o << "{";bool init = 1;for (auto e : v) {if (init) { init = 0; }else { o << ", "; }o << e;}o << "}";return o;}const int SUM_SUP = 20001;const int PARTITION_SUP = 101;const int MOD = 1000000007;vector<vector<int> > partition_number(SUM_SUP, vector<int>(PARTITION_SUP, 0));void build_partition_number() {for (int k = 0; k < PARTITION_SUP; k++) {partition_number[0][k] = 1;}for (int n = 1; n < SUM_SUP; n++) {for (int k = 1; k <= PARTITION_SUP; k++) {if (k > n) {partition_number[n][k] = partition_number[n][n];} else {partition_number[n][k] = (partition_number[n][k-1] + partition_number[n-k][k])%MOD;}}}}int main() {// cin.tie(0);// ios::sync_with_stdio(false);ll n, s, k;cin >> n >> s >> k;build_partition_number();ll rest = s - n*(n-1)*k/2;ll ans;if (rest < 0)ans = 0;else {ans = partition_number[rest][n];}cout << ans << "\n";return 0;}