We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<cmath>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;intmain(){intt;cin>>t;while(t--){longintn;cin>>n;longlonginta[n];longlongints=0;longintc1=0,c2=0;for(inti=0;i<n;i++){cin>>a[i];if(a[i]==1)c1++;if(a[i]==2)c2++;}s+=c1*(n-1);s+=(c2*(c2-1))/2;cout<<s<<endl;}/* Enter your code here. Read input from STDIN. Print output to STDOUT */return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Pairwise Sum and Divide
You are viewing a single comment's thread. Return to all comments →
Simple question