結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2015-08-21 23:02:55 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 14 ms / 5,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 371 ms |
コンパイル使用メモリ | 43,136 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 01:27:44 |
合計ジャッジ時間 | 1,423 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int getInt()’: main.cpp:7:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | inline int getInt(){ int s; scanf("%d", &s); return s; } | ~~~~~^~~~~~~~~~
ソースコード
#define REP(i,n) for(int i=0; i<(int)(n); i++)typedef long long ll;#include <queue>#include <cstdio>inline int getInt(){ int s; scanf("%d", &s); return s; }#include <set>using namespace std;int main(){const int n = getInt();const int s = getInt();const int k = getInt();const ll mod = 1000000007;vector<ll> dp(s + 1);dp[s] = 1;REP(i,n){const int rest = n - i;vector<ll> tmp(s + 1);for(int t = 0; t < rest; t++){int d = (i == 0 ? 0 : k * rest);int p = s - t - d;ll sum = 0;while(p >= 0){sum = (sum + dp[p + d]) % mod;tmp[p] = (tmp[p] + sum) % mod;p -= rest;}//REP(i,s+1) printf("%d ", (int)tmp[i]); puts("");}//puts("");/*for(int p = 0; p <= s; p++){for(int j = (i == 0 ? 0 : k * rest); j <= p; j += rest){const int q = p - j;tmp[q] = (tmp[q] + dp[q + j]) % mod;}}*/dp.swap(tmp);}printf("%d\n", (int)dp[0]);return 0;}