fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int MAX = 2010;
  4. int x[MAX], y[MAX];
  5. int dist[MAX];
  6.  
  7. int Solve() {
  8. int n;
  9. scanf("%d", &n);
  10. for (int i = 0; i < n; ++i)
  11. scanf("%d %d", &x[i], &y[i]);
  12.  
  13. int ans = 0;
  14. for (int i = 0; i < n; ++i) {
  15. for (int j = 0; j < n; ++j) {
  16. int dx = x[i] - x[j], dy = y[i] - y[j];
  17. dist[j] = dx*dx + dy*dy;
  18. }
  19. sort(dist, dist+n);
  20. int k = 0;
  21. while (k < n) {
  22. int cnt = 0;
  23. int j = k+1;
  24. while (j < n && dist[j] == dist[k])
  25. ++j;
  26. cnt = j-k;
  27. ans += cnt * (cnt-1) / 2;
  28. k = j;
  29. }
  30. }
  31. return ans;
  32. }
  33.  
  34. int main() {
  35. int ntests;
  36. scanf("%d", &ntests);
  37. for (int nt = 1; nt <= ntests; ++nt) {
  38. printf("Case #%d: %d\n", nt, Solve());
  39. }
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
Standard output is empty