結果
| 問題 | No.8046 yukicoderの過去問 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-02 16:25:23 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,480 ms / 2,000 ms |
| コード長 | 534 bytes |
| 記録 | |
| コンパイル時間 | 1,912 ms |
| コンパイル使用メモリ | 34,176 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-07 10:06:38 |
| 合計ジャッジ時間 | 9,384 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:14:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
14 | scanf("%d", &K);
| ~~~~~^~~~~~~~~~
main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d", &x);
| ~~~~~^~~~~~~~~~
ソースコード
#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC target ("avx")
#include <stdio.h>
constexpr int MO = 1000000007;
int K, N;
int a[100010];
int dp[100010];
int main() {
scanf("%d", &K);
scanf("%d", &N);
for (int i = 0; i < N; ++i) {
int x;
scanf("%d", &x);
a[x] = 1;
}
dp[0] = 1;
for (int y = 0; y < K; ++y) {
const int c = dp[y];
for (int x = 1; x <= K - y; ++x) {
if ((dp[y + x] += a[x] * c) >= MO) {
dp[y + x] -= MO;
}
}
}
printf("%d\n", dp[K]);
return 0;
}