fork download
  1. #include <stdio.h>
  2.  
  3. int howmany = 0;
  4. int tree[] = {123, 124, 125, 126, 128, 129, 134, 135, 136, 138, 139, 145, 146, 148, 149, 156, 158, 159, 167, 168, 169, 178, 179, 189, 234, 235, 236, 238, 239, 245, 246, 248, 249, 256, 258, 259, 267, 268, 269, 278, 279, 289, 345, 346, 348, 349, 356, 358, 359, 367, 368, 369, 378, 379, 389, 456, 458, 459, 467, 468, 469, 478, 479, 489, 567, 568, 569, 578, 579, 589, 678, 679, 689, 789, 923};
  5.  
  6. int distance(int x1, int y1, int x2, int y2) {
  7. return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  8. }
  9.  
  10. int is_right_triangle(int a, int b, int c) {
  11. return (a * a + b * b == c * c || a * a + c * c == b * b || b * b + c * c == a * a);
  12. }
  13.  
  14. int main(void) {
  15. int n;
  16. scanf("%d", &n);
  17.  
  18. int x[n], y[n];
  19. for (int i = 0; i < n; i++) {
  20. scanf("%d %d", &x[i], &y[i]);
  21. }
  22.  
  23. for (int i = 0; i < 75; i++) {
  24. int a = tree[i] / 100 - 1;
  25. int b = (tree[i] % 100) / 10 - 1;
  26. int c = tree[i] % 10 - 1;
  27.  
  28.  
  29. if (is_right_triangle(distance(x[a], y[a], x[b], y[b]), distance(x[a], y[a], x[c], y[c]), distance(x[b], y[b], x[c], y[c]))) {
  30. howmany++;
  31. }
  32. }
  33.  
  34. printf("%d", howmany);
  35. return 0;
  36. }
  37.  
Success #stdin #stdout 0.01s 5312KB
stdin
5
-1 1
-1 0
0 0
1 0
1 1
stdout
7