fork download
  1. #include<bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. const int N=20;
  5. int a[N],mylcm[N][N] ,n,m;
  6. bool f[N];
  7. int go(int x){
  8. if(x==n) {
  9. bool ff=true;
  10. int s=0;
  11. for(int i=0;i<n;i++){
  12. if(f[i]) s++;
  13. for(int j=0;j<n;j++){
  14. if(i!=j&&f[i]&&f[j]){
  15. if(mylcm[i][j]<=m) ff=false;
  16. }
  17. }
  18. }
  19. if(ff) return s;
  20. else return 1;
  21. }
  22. int fth,sth;
  23. f[x]=1; fth=go(x+1);
  24. f[x]=0; sth=go(x+1);
  25. return max(fth,sth);
  26. }
  27. signed main(){
  28. ios::sync_with_stdio(false); cin.tie(nullptr);
  29. cin>>n>>m;
  30. for(int i=0;i<n;i++) cin>>a[i];
  31. for(int i=0;i<n;i++){
  32. for(int j=0;j<n;j++){
  33. mylcm[i][j]=a[i]*(a[j]/__gcd(a[i],a[j]));
  34. }
  35. }
  36. cout<<go(0);
  37. }
  38.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
Standard output is empty