結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
|
提出日時 | 2023-02-04 00:44:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 5,000 ms |
コード長 | 1,383 bytes |
コンパイル時間 | 825 ms |
コンパイル使用メモリ | 95,440 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-07-02 22:36:36 |
合計ジャッジ時間 | 2,034 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <iostream> #include <stack> #include <queue> #include <algorithm> #include <functional> #include <set> #include <map> #include <string> #include <vector> #include <cmath> #include<sstream> #include<list> #include<iomanip> #include <cstdlib> #include <cstring> #include <stack> #include <bitset> #include <cassert> #include <stdlib.h> #include <stdio.h> using namespace std; const int INF = 100000000; const long long LINF = 3e18 + 7; const int MAX_N = 2000010; const int MAX_W = 10002; const int MAX_ARRAYK = 100000; double PI = 3.14159265358979323846; //using ll = long long; // https://kmjp.hatenablog.jp/entry/2015/08/22/0930 long long dp[110][20010]; long long mod = 1000000007; int N, S, K; int main() { cin >> N >> S >> K; // 0人目だけは任意の(Nの倍数)円を寄付できる for (int k = 0; k <= S; k += N) { dp[0][k] = 1; } for (int i = 1; i < N; i++) { // t円にできるか? for (int t = 0; t <= S; t++) { // (i - 1)番目のひとよりk円余分に払う if (t >= K * (N - i)) { dp[i][t] += dp[i - 1][t - K * (N - i)]; } // 既に全体(t-(N - i))円払っているが // もう1円(全体でN - i円余分に払うケース if (t >= N - i) { dp[i][t] += dp[i][t - (N - i)]; } dp[i][t] %= mod; } } cout << dp[N - 1][S] << endl; return 0; }