fork(1) download
  1. #include <vector>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. unsigned K;
  8. while(cin>>K)
  9. {
  10. vector<unsigned> tab(K);
  11. for(unsigned k=0;k<K;++k) cin>>tab[k];
  12. unsigned para=0;
  13. for(unsigned i=0;i<K;++i) for(unsigned k=i+1;k<K;++k) para+=(tab[i]==tab[k]);
  14. cout<<para<<endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3232KB
stdin
3    9 9 9
4    9 9 9 9
5    9 9 9 9 9
6    9 9 9 9 9 9
stdout
3
6
10
15