結果
| 問題 |
No.8046 yukicoderの過去問
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-07 02:01:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,750 ms / 2,000 ms |
| コード長 | 422 bytes |
| コンパイル時間 | 420 ms |
| コンパイル使用メモリ | 32,128 KB |
| 最終ジャッジ日時 | 2025-01-10 07:23:12 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d%d",&k,&n);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:15:29: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | int a; scanf("%d",&a);
| ~~~~~^~~~~~~~~
ソースコード
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <cstdio>
using namespace std;
constexpr int MOD=1e9+7;
int k,n,f[100001],dp[100001];
int main(){
scanf("%d%d",&k,&n);
for(int i=0;i<n;i++){
int a; scanf("%d",&a);
f[a]=-1;
}
dp[0]=1;
for(int x=0;x<k;x++){
int v=dp[x];
for(int y=0;x+y<=k;y++){
dp[x+y]+=f[y]&v;
dp[x+y]-=MOD*(dp[x+y]>=MOD);
}
}
printf("%d\n",dp[k]);
return 0;
}