結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-14 16:01:58 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 1,672 bytes |
| コンパイル時間 | 2,744 ms |
| コンパイル使用メモリ | 249,652 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-08-14 16:02:03 |
| 合計ジャッジ時間 | 3,940 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define Rrep(i,n) for(int i=n-1;i>=0;i--)
#define Rrep1(i,n) for(int i=n;i>0;i--)
#define all(a) a.begin(),a.end()
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
#define INF ((ll)2e15)
#define IINF ((int)1e9)
const double PI = 3.1415926535897932384626433832795028841971;
template<typename T>inline bool chmax(T& a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T>inline bool chmin(T& a, T b) { return ((a > b) ? (a = b, true) : (false)); }
#define yesno(ans) cout<<((ans)?"Yes\n":"No\n")
bool eq(double a, double b) { return abs(a - b) < 0.0000001; }
const int di[4] = { 1,0,-1,0 };
const int dj[4] = { 0,-1,0,1 };
/*ACL
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
using mint=modint1000000007;
using vm=vector<mint>;
using vvm=vector<vm>;
using vvvm=vector<vvm>;
//*/
int solve() {
//分割数
ll N,S,K;cin>>N>>S>>K;
ll sub=K;
K=0;
rep(i,N)S-=K,K+=sub;
if(S<0){
cout<<0<<endl;
return 0;
}
vvl dp(N+1,vl(S+1,0));
dp[0][0]=1;
//rep1(i,S)dp[0][i]=1;
rep1(i,N)rep(j,S+1){
if(j-i>=0)
dp[i][j]+=dp[i][j-i];
dp[i][j]+=dp[i-1][j];
dp[i][j]%=1000000007;
}
cout<<dp[N][S]<<endl;
return 0;
}
int main()
{
std::cin.tie(0)->sync_with_stdio(0);
int T = 1;
//cin>>T;
while (T--)
{
solve();
}
return 0;
}