結果
問題 |
No.269 見栄っ張りの募金活動
|
ユーザー |
![]() |
提出日時 | 2015-09-22 04:56:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3,576 ms / 5,000 ms |
コード長 | 1,393 bytes |
コンパイル時間 | 526 ms |
コンパイル使用メモリ | 80,836 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-07-16 01:50:48 |
合計ジャッジ時間 | 17,142 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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); RREP(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; dp[i][j]=(dp[i][j+(N-i)]-dp[i+1][j+(N-i)-(N-i-1)*K])%mod; }else{*/ for(int k=0;0<=j-(N-i-1)*(K+k)-k;k++){ dp[i][j]+=dp[i+1][j-(N-i-1)*(K+k)-k]; 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; }