//#pragma GCC optimize ("O3") //#pragma GCC target("avx512f") //#pragma GCC optimize("unroll-loops") // #ifndef ONLINE_JUDGE // #define _GLIBCXX_DEBUG // #endif #include #include using namespace std; using namespace atcoder; #define int long long #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) #define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/ #define pb push_back #define pf push_front #define fi first #define se second #define eb emplace_back #define endl '\n' #define SZ(x) ((ll)(x).size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define debug(v) cout<<#v<<":";for(auto x:v){cout< Point; // Point typedef long long ll; typedef vector vl; typedef vectorvvl; typedef vectorvvvl; typedef vectorvvvvl; typedef vectorvvvvvl; typedef pair P; typedef tuple T; template using minpq=priority_queue,greater>; const ll MOD=1000000007LL; // const ll MOD=998244353LL; // using mint=modint998244353; using mint=modint1000000007; // using mint=modint; const ll mod=MOD; string abc="abcdefghijklmnopqrstuvwxyz"; string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; vl dx={0,0,1,-1,1,1,-1,-1}; vl dy={1,-1,0,0,-1,1,-1,1}; template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(bvm; typedef vectorvvm; typedef vectorvvvm; ll modpow(ll a, ll n,ll mod=MOD) { ll res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } vectordivisor(int n){ vectorres; for(int i=1;i*i<=n;i++){ if(n%i==0){ res.push_back(i); if(i != n/i) res.push_back(n/i); } } return res; } //素因数分解O(√n) mapprime_factor(ll n){ mapres; for(ll i=2;i*i<=n;i++){ while(n%i==0){ res[i]++; n/=i; } } if(n!=1)res[n]=1; return res; } struct edge{ ll to;ll cost; }; ll functional(int x){ if(x==0)return 1; else return x*functional(x-1); } int cntv[10]; int vec[10]; main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(12); /*--------------------------------*/ int n,k;cin>>n>>k; int ans=0; int ma=0; for(int i=1;i<=9;i++){ cin>>cntv[i]; if(cntv[i])chmax(ma,i); } if(n==1){ if(ma%k==0)cout<<1<exist; unordered_mapexist2; vectorvec(10); //重複してしまうので //1の数が何個、2の数が何個、としてdfs auto dfs=[&](int cur,int cnt,auto &dfs)->void{ if(cnt>n/2)return; if(cur==10){ if(cntv; string s; for(int i=1;i<=9;i++){ for(int j=0;jv2; string s2; vectorcnt2(10); for(int i=1;i<10;i++)cnt2[i]=cntv[i]; for(int i=0;iexist2.size())swap(exist,exist2); for(auto p:exist){ if(p.first==0)continue; ans+=p.second*exist2[k-p.first]; } ans+=exist[0]*exist2[0]; return; } for(int i=0;i<=cntv[cur];i++){ vec[cur]=i; dfs(cur+1,cnt+i,dfs); } return; }; dfs(1,0,dfs); cout<