3 solutions
-
0
Guest MOD
-
1
#define int long long #define endl '\n' using namespace std; int n,t,a[1000000]; map<int,int> c; signed main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin>>t; while(t--){ cin>>n; c.clear(); for(int i=1;i<=n;i++){ cin>>a[i]; } vector s,b; for(int i=1;i<=n;i++){ b.clear(); if(a[i]<=10000){ c[a[i]]=1; b.push_back(a[i]); } for(auto v:s){ int l=v*a[i]/__gcd(v,a[i]); if(l>10000)break; c[l]=1; if(b.empty()||b.back()!=1)b.push_back(l); } s.swap(b); } int ans=1; while(ans<=10000&&c[ans])ans++; cout<<ans<<endl; }
return 0;}
Information
- ID
- 1596
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- (None)
- # Submissions
- 44
- Accepted
- 1
- Uploaded By