結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
|
提出日時 | 2015-09-04 20:27:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 480 ms |
コンパイル使用メモリ | 55,296 KB |
実行使用メモリ | 19,216 KB |
最終ジャッジ日時 | 2024-07-16 01:49:17 |
合計ジャッジ時間 | 1,327 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; const ll mod = 1e9 + 7; const int N = 101; const int S = 20010; ll dp[N][S]; int main(void){ int n,s,k; cin >> n >> s >> k; int r = s - k * n * (n - 1) / 2; if (r < 0) { cout << 0 << endl; return 0; } REP(i, 0, S) { dp[0][i] = 0; } dp[0][0] = 1; REP(i, 0, n) { REP(j, 0, S) { int w = i + 1; ll sub = dp[i][j]; if (j >= w) { sub += dp[i + 1][j - w]; } sub %= mod; dp[i + 1][j] = sub; } } cout << dp[n][r] << endl; }