Advertisement
Guest User

NIGERIAN

a guest
Mar 31st, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. { vector<int> prime ={2,3,5,7,11,13,17,19,23,29,21};
  7.  
  8. int t; cin >> t;
  9.  
  10. while(t--){
  11. int n; cin >> n;
  12. vector<int> num[n];
  13. vector<int> color(n, 0);
  14. for (auto& numi : num) cin >> numi;
  15.  
  16. int colused = 1;
  17. for(int i=0;i<11;i++){
  18. int cnt = 0;
  19. for(int j = 0;j<n;j++){
  20. if(color[j] == 0 && num[j]%prime[i] == 0){
  21. cnt++;
  22. color[i] = colused;
  23. }
  24. }
  25. if(cnt!=0){
  26. colused++;
  27. }
  28. }
  29. cout << colused - 1 << endl;
  30. for(int i = 0;i<n;i++){
  31. cout << color[i] << " ";
  32. }
  33. cout << endl;
  34. }
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement