結果
| 問題 | No.137 貯金箱の焦り |
| コンテスト | |
| ユーザー |
kcm1700
|
| 提出日時 | 2015-01-26 00:47:10 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 5,000 ms |
| コード長 | 562 bytes |
| 記録 | |
| コンパイル時間 | 1,154 ms |
| コンパイル使用メモリ | 167,864 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-08 16:01:00 |
| 合計ジャッジ時間 | 3,572 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%lld",&n,&m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:14:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | for (int i = 0; i < n; i++) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <algorithm>
using namespace std;
const int mod = 1234567891;
long long dt[80001];
int a[50];
int main() {
int n;
long long m;
scanf("%d%lld",&n,&m);
for (int i = 0; i < n; i++) scanf("%d",&a[i]);
int sum = accumulate(a,a+n,0);
dt[0] = 1;
while(m) {
for (int i = 0; i < n; i++) for (int j = sum*2; j >= a[i]; j--) dt[j] = (dt[j] + dt[j-a[i]]) % mod;
for (int i = 0; i <= sum; i++) dt[i] = dt[i*2+m%2];
for (int i = sum+1; i <= sum*2; i++) dt[i] = 0;
m /= 2;
}
printf("%lld\n", dt[0]);
return 0;
}
kcm1700