結果

問題 No.8046 yukicoderの過去問
ユーザー fura
提出日時 2020-05-07 01:41:17
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 420 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 29,440 KB
最終ジャッジ日時 2025-01-10 07:22:09
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:15:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |         scanf("%d%d",&k,&n);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:16:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |         rep(i,n) scanf("%d",&a[i]);
      |                  ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <cstdio>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

constexpr int MOD=1e9+7;

int k,n,a[100000],dp[200001];

int main(){
	scanf("%d%d",&k,&n);
	rep(i,n) scanf("%d",&a[i]);

	dp[0]=1;
	for(int x=0;x<k;x++){
		for(int i=0;i<n;i++){
			dp[x+a[i]]+=dp[x];
			dp[x+a[i]]-=MOD*(dp[x+a[i]]>=MOD);
		}
	}
	printf("%d\n",dp[k]);

	return 0;
}
0