Untitled

 avatar
user_5668965
c_cpp
9 days ago
922 B
1
Indexable
Never
#include <iostream>
#include <cstring>
using namespace std;

typedef long long ll;

ll ans = 0;
int cnt[1000005];

void f(int temp) {
    for (int i = 2; i * i <= temp; i++) {
        if (temp % i == 0) {
            if (cnt[i] == 0) ans++;
            cnt[i]++;
            if (cnt[i] == 3) cnt[i] = 0;
            while (temp % i == 0) {
                temp /= i;
            }
        }
    }
    if (temp > 1) {
        if (cnt[temp] == 0) ans++;
        cnt[temp]++;
        if (cnt[temp] == 3) cnt[temp] = 0;
    }
}

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        ans = 0;
        memset(cnt, 0, sizeof(cnt));
        
        int n;
        scanf("%d", &n);
        
        for (int i = 1; i <= n; i++) {
            int a;
            scanf("%d", &a);
            f(a);
        }
        
        cout << ans << endl;
    }
    return 0;
}
Leave a Comment