#include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <cstdlib> #include <cmath> #include <set> #include <map> #include <vector> #include <cstring> #define INF 100000000 using namespace std; long long int gcd(long long a,long long b){ return b == 0?a:gcd(b,a%b); } int main(){ int t; scanf("%d",&t); while(t--){ long long int n; cin >> n; map<string,int> a; int odd = 0; for(int i = 0;i < n;i++){ string b; cin >> b; odd += b.length()%2; if(a.find(b)!=a.end()){ a[b]++; } else{ a[b] = 1; } } long long int ans = 0; for(map<string,int>::iterator ite = a.begin();ite != a.end();ite++){ long long int t = ite->second; ans += t*(t-1)/2; } ans += odd*(n-odd); // cout << ans << endl; long long tmp = n * (n-1)/2; long long int gc = gcd(tmp,ans); cout << ans/gc << "/" << tmp/gc << endl; // printf("%d/%d\n",ans/gc,tmp/gc); } return 0; }
时间: 2024-10-19 23:59:08