fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. long long Solve() {
  5. int n;
  6. scanf("%d", &n);
  7. vector<int> x(n), y(n);
  8. for (int i = 0; i < n; ++i)
  9. scanf("%d %d", &x[i], &y[i]);
  10.  
  11. long long ans = 0;
  12. for (int i = 0; i < n; ++i) {
  13. unordered_map<int,int> dist_cnt;
  14. for (int j = 0; j < n; ++j) {
  15. int dx = x[i] - x[j], dy = y[i] - y[j];
  16. ++dist_cnt[dx*dx + dy*dy];
  17. }
  18. for (const auto& p : dist_cnt) {
  19. ans += p.second * (p.second-1) / 2;
  20. }
  21. }
  22. return ans;
  23. }
  24.  
  25. int main() {
  26. int ntests;
  27. scanf("%d", &ntests);
  28. for (int nt = 1; nt <= ntests; ++nt) {
  29. printf("Case #%d: %lld\n", nt, Solve());
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty