結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-21 23:07:56 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,462 ms / 5,000 ms |
コード長 | 827 bytes |
コンパイル時間 | 779 ms |
コンパイル使用メモリ | 75,716 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 12:08:18 |
合計ジャッジ時間 | 8,735 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <iostream>#include <vector>#include <cstdio>#include <sstream>#include <map>#include <string>#include <algorithm>#include <queue>#include <cmath>#include <set>using namespace std;#define MOD 1000000007ostream& operator << (ostream& os, vector<long long>& v){for(int i=0; i<v.size(); i++){os << v[i] << " ";}return os;}int main(){long long n,s,k;cin >> n >> s >> k;vector<long long> dp(s+1, 0);for(int i=0; i<=s; i++){if(s < i*n) break;dp[s - i*n] = 1;}//cerr << dp << endl;for(int i=1; i<n; i++){vector<long long> dp_(s+1, 0);for(int j=0; j<=s; j++){for(int a=k; a<=s; a++){if(j-a*(n-i) < 0) break;long long& nx = dp_[ j-a*(n-i) ];nx = nx + dp[j];if(nx >= MOD) nx -= MOD;}}swap(dp, dp_);}cout << dp[0] << endl;return 0;}