提交时间:2024-05-12 06:38:17
运行 ID: 146497
#include <iostream> #include <algorithm> #include <cstring> using namespace std; const int N = 110, M = 25000 + 10; int T, n; int v[101]; bool f[25001]; int main() { cin >> T; while (T--) { cin >> n; for (int i = 1; i <= n; i++) cin >> v[i]; sort(v + 1, v + 1 + n); int res = 0; //f[0] = true; for (int i = 1; i <= n; i++) { if (f[v[i]]==0) { res++; for (int j = 2; j*v[i] <= v[n]; j++) { f[j*v[i]] = 1; } } } cout << res << endl; memset(v, 0, sizeof v); memset(f, false, sizeof f); } return 0; }