fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdbool.h>
  4.  
  5. #define MAX 2010
  6. #define MOD 32767
  7. #define clr(ar) memset(ar, 0, sizeof(ar))
  8. #define read() freopen("lol.txt", "r", stdin)
  9.  
  10. int t, n, m, X[MAX], Y[MAX], id[MOD + 6667], hash[MOD + 6667], counter[MOD + 6667];
  11.  
  12. int F(int i, int j){
  13. int x = (X[i] - X[j]);
  14. int y = (Y[i] - Y[j]);
  15. return ((x * x) + (y * y));
  16. }
  17.  
  18. int find(int x){
  19. int i = x & MOD, res = 0;
  20. while (id[i] == m && hash[i] != x) i++;
  21. if (id[i] == m){
  22. res = counter[i];
  23. counter[i]++;
  24. }
  25. else hash[i] = x, counter[i] = 1, id[i] = m;
  26. return res;
  27. }
  28.  
  29. int main(){
  30. int T = 0, i, j, k, l;
  31.  
  32. scanf("%d", &t);
  33. while (t--){
  34. scanf("%d", &n);
  35. for (i = 0; i < n; i++) scanf("%d %d", &X[i], &Y[i]);
  36.  
  37. long long res = 0;
  38. for (i = 0; i < n; i++){
  39. m++;
  40. for (j = 0; j < n; j++){
  41. res += find(F(i, j));
  42. }
  43. }
  44.  
  45. printf("Case #%d: %lld\n", ++T, res);
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0s 3936KB
stdin
Standard input is empty
stdout
Standard output is empty