結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2018-08-29 20:01:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 1,297 bytes |
コンパイル時間 | 549 ms |
コンパイル使用メモリ | 64,144 KB |
実行使用メモリ | 11,400 KB |
最終ジャッジ日時 | 2024-07-16 02:07:27 |
合計ジャッジ時間 | 1,269 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
// https://yukicoder.me/problems/no/269// status:// tag: [分割数]// ref: http://d.hatena.ne.jp/incognita/20110305/1299344781// ref: http://drken1215.hatenablog.com/entry/2018/01/16/222843#define SUBMIT//#define DEBUG#include <algorithm>#include <cstring>#include <iomanip>#include <iostream>using namespace std;using ui64 = unsigned long long;using i64 = long long;const int M = 1000000000 + 7;const int MAX_S = 20000;const int MAX_N = 100;// dp[N][S] SのN分割の総数// dp[n][s] = dp[n][s - n] + dp[n - 1][s] (s >= n)// dp[n][s] = dp[n][s - 1] (otherwise)int dp[MAX_N + 1][MAX_S + 1];int N, S, K;// 分割数// nのm分割を求めるint solve_partition(int m, int n) {// initmemset(dp, 0, sizeof(dp));dp[0][0] = 1;// partitionfor (int i = 1; i <= m; ++i) {for (int j = 0; j <= n; ++j) {if (j - i >= 0) dp[i][j] = (dp[i - 1][j] + dp[i][j - i]) % M;else dp[i][j] = dp[i - 1][j] % M;}}return dp[m][n];}int main() {#ifdef SUBMITauto& stream = cin;#elsestringstream stream(R"(55 2555 1)");#endifstream >> N >> S >> K;for (int i = 0; i < N; ++i) S -= i * K;auto ans = solve_partition(N, S);cout << ans << endl;return 0;}