1 solutions

  • 0
    @ 2025-12-27 9:45:23
    #include<bits/stdc++.h>
    using namespace std;
    
    # define int long long
    int n, ca, sz[200005], tong[200006];
    
    signed main() {
    
    
    	cin >> n;
    	for (int i = 1; i <= n; i++) {
    		cin >> sz[i];
    		if (sz[i] == 0)tong[0]++;
    		else {
    			for (int it = 2; it * it <= sz[i]; it ++ ) {
    				while (sz[i] % (it * it) == 0) {
    					sz[i] /= it * it;
    				}
    			
    			}
    				tong[sz[i]]++;
    
    		}
    
    	}
    	int total=0;
    	for(int i=1;i<=200000;i++)
    	total+=(tong[i]-1)*tong[i]/2;
    	cout<<(total+(n-tong[0])*tong[0]+(tong[0]-1)*tong[0]/2);
    
    
    }
    
    
    • 1

    Information

    ID
    846
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    6
    Tags
    (None)
    # Submissions
    42
    Accepted
    13
    Uploaded By