fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. #define ll long long
  5. #define pb push_back
  6. #define fi first
  7. #define se second
  8. #define nn '\n'
  9. #define pi pair<ll,ll>
  10. #define unmp unordered_map
  11. #define uns unordered_set
  12. #define TASK ""
  13. ll mod = 1e9+7;
  14. const int N = 1e5 + 5;
  15. int MOD = 998244353;
  16. int bit[200000];
  17. int n;
  18. int dem = 0;
  19. unmp<int, int> cnt;
  20. int daoso(int n){
  21. string t;
  22. while(n > 0){
  23. int d = n % 10;
  24. string k = to_string(d);
  25. t += k;
  26. n /= 10;
  27. }
  28. int kq = stoi(t);
  29. return kq;
  30. }
  31. int main() {
  32. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  33. if(fopen(TASK".INP","r")){
  34. freopen(TASK".INP","r",stdin);
  35. freopen(TASK".OUT","w",stdout);
  36. }
  37. cin >> n;
  38. for(int i = 1; i <=n ; i++){
  39. int x; cin >> x;
  40. int target = daoso(x);
  41. dem += cnt[target];
  42. cnt[x]++;
  43. }
  44. cout << dem << nn;
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0.01s 5288KB
stdin
6
123 123 456 321 654 789
stdout
3