結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
|
提出日時 | 2023-12-01 10:39:32 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 1,077 bytes |
コンパイル時間 | 2,244 ms |
コンパイル使用メモリ | 202,324 KB |
最終ジャッジ日時 | 2025-02-18 02:53:37 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> #define rep(i, p, n) for (ll i = p; i < (ll)(n); i++) #define rep2(i, p, n) for(ll i = p; i >= (ll)(n); i-- ) using namespace std; using ll = long long; double pi=3.141592653589793; const long long inf=2*1e9; const long long linf=8*1e18; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } //atcoder #include <atcoder/modint> #include <atcoder/dsu> using namespace atcoder; using mint1 = modint1000000007; using mint2 = modint998244353; int main() { ll N, S, K; cin >> N >> S >> K; S-=((N-1)*N/2)*K; if (S<0) { cout << 0 << endl; return 0; } vector<vector<mint1>> dp(S+1, vector<mint1>(N+1)); rep(i, 0, N+1) { dp.at(0).at(i)=1; } rep(i, 0, S) { rep(j, 0, N+1) { mint1 A=0; if (j>0) { A=dp.at(i+1).at(j-1); } mint1 B=0; if ((i+1)>=j) { B=dp.at(i+1-j).at(j); } dp.at(i+1).at(j)=A+B; } } cout << dp.at(S).at(N).val(); }