SHARE
TWEET

231

a guest Nov 8th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cassert>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int n;
  9.  
  10. int a[2010];
  11. int cnt[16];
  12.  
  13. int main(int, char *args[])
  14. {
  15.     #ifndef ONLINE_JUDGE
  16.     freopen(args[1], "r", stdin);
  17.     freopen(args[2], "w", stdout);
  18.     #endif
  19.  
  20.     assert(scanf("%d", &n) == 1);
  21.  
  22.     assert(1 < n && n < 2011);
  23.    
  24.     memset(cnt, 0, sizeof cnt);
  25.    
  26.     for(int i = 0; i < n; i++)
  27.     {
  28.         assert(scanf("%d", &a[i]) == 1);
  29.         assert(1 <= a[i] && a[i] <= 15);
  30.         cnt[a[i]]++;
  31.     }
  32.  
  33.     int all = 1 << 15;
  34.     int best = n;
  35.     for(int i = 0; i < all; i++)
  36.     {
  37.         bool ok = true;
  38.         int cur = 0;
  39.         for(int j = 0; j < 15; j++) if (!(i & (1 << j))) cur += cnt[j + 1];
  40.        
  41.         if (cur >= best) continue;
  42.        
  43.         for(int j = 0; j < 15; j++)
  44.             if (cnt[j + 1])
  45.             if (i & (1 << j))
  46.             for(int k = j + 1; k < 15; k++)
  47.             if (cnt[k + 1])
  48.             if (i & (1 << k))
  49.             if ((k + 1) % (j + 1) == 0) ok = false;
  50.            
  51.         if (ok) best = cur;
  52.     }
  53.    
  54.     printf("%d\n", best);
  55.    
  56.     return 0;
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top