結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2015-08-21 23:29:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,592 ms / 5,000 ms |
| コード長 | 781 bytes |
| コンパイル時間 | 1,333 ms |
| コンパイル使用メモリ | 160,496 KB |
| 実行使用メモリ | 11,264 KB |
| 最終ジャッジ日時 | 2024-07-16 01:30:15 |
| 合計ジャッジ時間 | 7,681 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int sum[20210] = {};
int dp[110][20110];
int N,S,K;
vector<int> v;
int dfs(int x,int s){
if( s < 0 ) return 0;
if( dp[x][s] != -1 ) return dp[x][s];
if( x == 0 ){
return s == 0;
}
int ans = 0;
for(int i = 0 ; ; i++){
int c = i * x;
if( c > s ) break;
ans += dfs(x-1,s-c);
ans %= 1000000007;
}
return dp[x][s] = ans;
}
int main(){
cin >> N >> S >> K;
S -= K*N*(N-1)/2;
if( S < 0 ) cout << 0 << endl;
else{
dp[N][S] = 1;
for(int x = N ; x >= 1 ; x--){
for(int s = 0 ; s <= S ; s++){
for(int k = 0 ; ; k++){
int c = k * x;
if( c > s ) break;
dp[x-1][s-c] += dp[x][s];
if( dp[x-1][s-c] >= 1000000007 ) dp[x-1][s-c] -= 1000000007;
}
}
}
cout << dp[0][0] << endl;
}
}
kyuridenamida