結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
Goi_dude
|
| 提出日時 | 2020-03-08 20:16:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 5,000 ms |
| コード長 | 1,062 bytes |
| コンパイル時間 | 2,129 ms |
| コンパイル使用メモリ | 158,320 KB |
| 実行使用メモリ | 12,672 KB |
| 最終ジャッジ日時 | 2024-11-07 16:21:48 |
| 合計ジャッジ時間 | 2,426 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 }; // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
int dp[101][20002];
int f(int n,int s){
// K = 0 のとき n人でsを分ける方法
if(n == 0 && s == 0)return 1;
if(n<=0 || s<0)return 0;
if(dp[n][s]!=-1)return dp[n][s];
dp[n][s] = f(n-1,s) % mod + f(n,s-n) % mod;
return dp[n][s] % mod;
}
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(20);
rep(i,101)rep(j,20002)dp[i][j] = -1;
int N,S,K;
cin >> N >> S >> K;
S -= K*N*(N-1)/2;
cout << f(N,S) % mod << endl;
}
Goi_dude