結果
| 問題 |
No.269 見栄っ張りの募金活動
|
| コンテスト | |
| ユーザー |
hiroa
|
| 提出日時 | 2019-08-09 18:27:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3,818 ms / 5,000 ms |
| コード長 | 685 bytes |
| コンパイル時間 | 1,426 ms |
| コンパイル使用メモリ | 167,644 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-07-19 07:40:51 |
| 合計ジャッジ時間 | 12,532 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
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 N,S,K;
ll dp[101][20010];
ll dfs(int n,int y){
if(y<0) return 0;
if(n==N-1) return 1;
ll& ret=dp[n][y];
if(ret>=0) return ret;
ret=0;
for(int i=0;i*(N-n)<=y;i++){
ret+=dfs(n+1,y-i*(N-n));
}
ret%=MOD;
return ret;
}
int main(void) {
cin>>N>>S>>K;
dp[0][0]=1;
S-=N*(N-1)/2*K;
memset(dp,-1,sizeof(dp));
cout<<dfs(0,S)<<endl;
}
hiroa