結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-22 07:59:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4,530 ms / 5,000 ms |
コード長 | 919 bytes |
コンパイル時間 | 1,257 ms |
コンパイル使用メモリ | 158,180 KB |
実行使用メモリ | 12,144 KB |
最終ジャッジ日時 | 2024-07-16 01:32:47 |
合計ジャッジ時間 | 14,157 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h>#define mp make_pair#define mt make_tuple#define pb push_back#define rep(i,n) for(int i=0;i<(n);i++)using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int,int> pii;typedef pair<long,long> pll;const int INF=1<<29;const double EPS=1e-9;const int MOD = 1000000007;const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};int N,S,K;int dp[110][20010];int memo(int pos, int sum){if (sum > S){return 0;}if (pos == N - 1){return 1;}int res = dp[pos][sum];if (res >= 0){return res;}res = 0;for (int i = 0; sum + i * (N - pos) <= S; i++){res += memo(pos + 1, sum + i * (N - pos));res %= MOD;}dp[pos][sum] = res;return res;}int main(){cin >> N >> S >> K;memset(dp, -1, sizeof(dp));S -= N * (N - 1) / 2 * K;cout << memo(0, 0) << endl;return 0;}