結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-21 16:07:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,515 ms / 5,000 ms |
| コード長 | 684 bytes |
| コンパイル時間 | 642 ms |
| コンパイル使用メモリ | 69,308 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-16 01:57:31 |
| 合計ジャッジ時間 | 6,442 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
using namespace std;
const int mod = 1e9+7;
int main() {
int n, s, k; cin >> n >> s >> k;
s -= k * (n-1)*n/2;
if (s < 0) {
cout << 0 << endl;
} else {
vector<int> dp(s+1);
dp[0] = 1;
repeat (i,n) {
repeat_reverse (j,s+1) {
for (int a = 1; j + a*(n-i) < s+1; ++ a) {
dp[j + a*(n-i)] += dp[j];
dp[j + a*(n-i)] %= mod;
}
}
}
cout << dp[s] << endl;
}
return 0;
}