fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int chap(int k, int n){
  4. if(k == 0 || k == n) return 1;
  5. else if(k == 1) return n;
  6. return chap(k - 1, n - 1) + chap(k, n - 1);
  7. }
  8. int main()
  9. {
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(NULL);
  12. int n; cin >> n;
  13. int a[n + 1];
  14. map <int, int> mp;
  15. for(int i = 0 ; i < n ; ++i){
  16. cin >> a[i];
  17. ++mp[a[i]];
  18. }
  19. int ans = 0;
  20. for(auto it : mp){
  21. if(it.second == 2) ++ans;
  22. else if(it.second > 2) ans += chap(2, it.second);
  23. }
  24. cout << ans;
  25. return 0;
  26. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
11073981