結果
問題 | No.269 見栄っ張りの募金活動 |
ユーザー |
![]() |
提出日時 | 2019-02-27 22:57:37 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 19 ms / 5,000 ms |
コード長 | 399 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 34,012 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 05:22:40 |
合計ジャッジ時間 | 1,273 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%lld%lld%lld", &n, &s, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<algorithm>using namespace std;typedef long long ll;ll n, s, k, dp[20001], mod = 1e9 + 7;int main() {scanf("%lld%lld%lld", &n, &s, &k);ll sum = s - n * (n - 1) * k / 2;if (sum < 0) { printf("0\n"); return 0; }dp[0] = 1;for (ll i = n; i >= 1; i--) {for (ll j = i; j <= sum; j++) dp[j] = (dp[j] + dp[j - i]) % mod;}printf("%lld\n", dp[sum]);}