| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 43389 | 范墨涵 | 【J】T2 | C++ | Accepted | 100 | 0 MS | 248 KB | 770 | 2026-10-29 13:54:41 |
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 25; int t; int n,A; int ans; int a[N]; void dfs(int st,int x){ if (st>ans) return ; for (int i=1;i<=n;i++){ if (a[i]>x) continue; if (x%a[i]==0){ ans=st; return ; } dfs(st+1,x%a[i]); } return ; } bool cmp(int a,int b){ return a>b; } signed main(){ // freopen("a.in","r",stdin); // freopen("a.out","w",stdout); cin >> t; while (t--){ cin >> n >> A; for (int i=1;i<=n;i++) cin >> a[i]; sort (a+1,a+1+n,cmp); ans=30; dfs(1,A); if (ans==30) cout << -1 << endl; else cout << ans << endl; } return 0; }