結果
問題 | No.8046 yukicoderの過去問 |
ユーザー |
![]() |
提出日時 | 2020-08-03 20:56:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,837 ms / 2,000 ms |
コード長 | 729 bytes |
コンパイル時間 | 3,008 ms |
コンパイル使用メモリ | 214,276 KB |
最終ジャッジ日時 | 2025-01-12 13:56:23 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘void input()’: main.cpp:19:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | repeat(i, N) scanf("%d", X + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include "bits/stdc++.h" using namespace std; #define repeat(cnt,l) for(auto cnt=decltype(l)();(cnt)<(l);++(cnt)) // const int MD = 1000000007; int N, K; int X[100010]; void input() { cin >> K >> N; repeat(i, N) scanf("%d", X + i); } // int dp[100010]; int f[100010]; int solve() { fill(dp, dp + K + 1, 0); fill(f, f + K + 1, 0); repeat(i, N) f[X[i]] = 1; dp[0] = 1; repeat(k, K) { const int v = dp[k]; repeat(i, K - k + 1) { dp[i + k] += v * f[i]; dp[i + k] -= MD*(dp[i + k] >= MD); } } return dp[K]; } int main() { input(); cout << solve() << endl; return 0; }