結果
| 問題 | No.269 見栄っ張りの募金活動 |
| コンテスト | |
| ユーザー |
sntea
|
| 提出日時 | 2015-11-05 16:25:44 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 5,000 ms |
| コード長 | 1,629 bytes |
| 記録 | |
| コンパイル時間 | 884 ms |
| コンパイル使用メモリ | 79,644 KB |
| 実行使用メモリ | 18,944 KB |
| 最終ジャッジ日時 | 2024-07-16 01:51:11 |
| 合計ジャッジ時間 | 1,358 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <utility>
#define endl '\n'
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef pair<int,int> P;
typedef long long int LL;
const int MAX_N=100,MAX_S=20000,MAX_K=100;
const int mod=1000000007;
LL dp[MAX_N][MAX_S+1];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int N,S,K;
cin>>N>>S>>K;
RREP(i,N){
//DEBUG(i);
REP(j,S+1){
// DEBUG(j);
if(i==N-1){
dp[i][j]=1;
}else{
/*if(N-i-1<=j&&j+(N-i)<=S){
//cout<<i<<' '<<j<<endl;
//if(!(0<=j+(N-i)-(N-i-1)*K&&j+(N-i)-(N-i-1)*K<=S)) cout<<"hoge"<<endl;
//if(dp[i][j+(N-i)]>=0&&dp[i+1][j+(N-i)-(N-i-1)*K]>=0&&dp[i][j+(N-i)]-dp[i+1][j+(N-i)-(N-i-1)*K]<=0) cout<<i<<' '<<j<<endl;
dp[i][j]=(dp[i][j+(N-i)]-dp[i+1][j+(N-i)-(N-i-1)*K])%mod;*/
if(j-K*(N-i-1) > N-i){
dp[i][j] = dp[i][j-(N-i)]+dp[i+1][j-K*(N-i-1)];
dp[i][j] %= mod;
}else{
for(int k=0;0<=j-K*(N-i-1)-k*(N-i);k++){
dp[i][j]+=dp[i+1][j-K*(N-i-1)-k*(N-i)];
dp[i][j]%=mod;
}
}
}
}
}
/*REP(i,N){
REP(j,S+1){
cout<<dp[i][j]<<' ';
/*if(dp[i][j]>=mod){
cout<<i<<' '<<j<<endl;
}
}
cout<<endl;
}*/
cout<<dp[0][S]<<endl;
return 0;
}
sntea