結果
| 問題 | No.269 見栄っ張りの募金活動 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-04 13:15:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 5,000 ms |
| コード長 | 1,089 bytes |
| 記録 | |
| コンパイル時間 | 3,810 ms |
| コンパイル使用メモリ | 255,576 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2025-12-04 13:15:11 |
| 合計ジャッジ時間 | 5,379 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); ++i)
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;
int gcd(int a, int b){
if(b == 0) return a;
else return gcd(b, a%b);
}
struct Compare {
bool operator()(const pair<ll, int>& a, const pair<ll, int>& b) {
return a.first > b.first;
}
};
ll mod = 1e9 + 7;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,s,k; cin >> n >> s >> k;
vector<vector<ll>> dp(n+1, vector<ll>(s+1, 0));
dp[0][0] = 1;
for(int i=0;i<=n;i++){
rep(j,s+1){
if(j - k*(n-i) >= 0 && i > 0) dp[i][j] += dp[i-1][j-k*(n-i)];
dp[i][j] %= mod;
if(j - (n-i) >= 0) dp[i][j] += dp[i][j-(n-i)];
dp[i][j] %= mod;
}
}
cout << dp[n-1][s] << endl;
return 0;
}