結果
問題 |
No.8046 yukicoderの過去問
|
ユーザー |
|
提出日時 | 2020-08-18 08:01:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,864 ms / 2,000 ms |
コード長 | 1,419 bytes |
コンパイル時間 | 1,953 ms |
コンパイル使用メモリ | 124,152 KB |
最終ジャッジ日時 | 2025-01-13 02:52:47 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx") #include <stdio.h> #include <iostream> #include <vector> #include <algorithm> #include <map> #include <queue> #include <cstdio> #include <ctime> #include <assert.h> #include <chrono> #include <random> #include <numeric> #include <set> #include <deque> #include <stack> #include <bitset> using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } constexpr int mod=1000000007; int n,k,x; int dp[100010]; int f[100010]; const int BS=524288; int CNT,rc; char inb[BS]; inline char gchar(void){ if(CNT%BS==0){ CNT=0; rc=fread(inb,1,BS,stdin); } return CNT<rc?inb[CNT++]:0; } inline int _readint(int *ptr){ int n=0,c=0; *ptr=0; while(1){ char read=gchar(); if(read>='0'&&read<='9')read-='0',n*=10,n+=read; else{*ptr=n;return n==0?0:!c;} c++; } *ptr=n; return 0; } inline int readint(void){int ptr;while(_readint(&ptr));return ptr;} int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); k=readint(); n=readint(); for(int i=0;i<n;i++){ x=readint(); f[x]=1; } dp[0]=1; for(int i=0;i<k;i++){ const int v=dp[i]; for(int j=0;j<k-i+1;j++){ dp[i+j]+=v*f[j]; dp[i+j]-=mod*(dp[i+j]>=mod); } } cout << dp[k] << "\n"; }