Saleh127

At coder 114A

Mar 14th, 2021
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. ll p[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
  6. ll a[100],ans=1e18;
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(0);
  10. cin.tie(0);cout.tie(0);
  11.  
  12. ll n,i,j,k,l;
  13.  
  14. cin>>n;
  15.  
  16. for(i=1;i<=n;i++)
  17. {
  18. cin>>a[i];
  19. }
  20.  
  21. for(i=1;i<(1<<15);i++)
  22. {
  23. ll c=1;
  24. for(j=0;j<15;j++)
  25. {
  26. if(i&(1<<j)) c*=p[j];
  27. }
  28. ll k=0;
  29. for(l=1;l<=n;l++)
  30. {
  31. if(__gcd(a[l],c)==1)
  32. {
  33. k=1;
  34. break;
  35. }
  36. }
  37. if(k==0) ans=min(ans,c);
  38. }
  39.  
  40. cout<<ans<<endl;
  41.  
  42. return 0;
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment