// lanqiao2942 数字王国之军训排队 #include using namespace std; const int N = 15; int a[N], n; vector v[N]; // 剪枝 bool dfs(int cnt, int dep){ if(dep == n+1){ return true; } // 枚举每个人所属的队伍 for(int i = 1; i <= cnt; i++){ bool tag = true; for(const auto &j:v[i]){ if(a[dep] % j == 0){ tag = false; break; } } if(!tag) continue; v[i].push_back(a[dep]); if(dfs(cnt, dep + 1)) return true; // 恢复现场 v[i].pop_back(); } return false; } int main(){ cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]; sort(a+1, a+1+n); for(int i = 1; i <= n; i++){ if(dfs(i, 1)){ cout << i << '\n'; break; } } return 0; } /* test samples 4 2 3 4 4 */