結果

問題 No.8046 yukicoderの過去問
コンテスト
ユーザー ciel
提出日時 2019-04-07 21:04:39
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
コンパイル:
g++-12 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1,217 ms / 2,000 ms
コード長 470 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 455 ms
コンパイル使用メモリ 50,304 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-07 10:15:10
合計ジャッジ時間 9,032 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         scanf("%d%d",&K,&N);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:15:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         for(int i=0,y;i<N;i++)scanf("%d",&y),x[y]=1;
      |                               ~~~~~^~~~~~~~~

ソースコード

diff #
raw source code

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <vector>
#include <cstdio>
using namespace std;

int k[1<<17],x[1<<17];
const int M=1000000007;
int main(){
	int K,N;
	scanf("%d%d",&K,&N);
	//vector<int> k(K+1);
	//vector<int> x(K);
	k[0]=1;
	for(int i=0,y;i<N;i++)scanf("%d",&y),x[y]=1;
	for(int l=0;l<K;l++){
		int v=k[l];
		for(int i=0;l+i<=K;i++){
			k[l+i]+=x[i]*v;
			if(k[l+i]>=M)k[l+i]-=M;
			//k[l+i]-=M*(k[l+i]>=M);
		}
	}
	printf("%d\n",k[K]);
}
0