fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double dist(int x1, int y1, int x2, int y2)
  5. {
  6. int sum = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  7.  
  8. return sqrt((double)sum);
  9. }
  10. int main()
  11. {
  12. int x1, y1, x2, y2;
  13. int X, Y, R, planetNum,repeatNum;
  14. int isPass=0;
  15.  
  16. for (scanf("%d", &repeatNum); repeatNum > 0; repeatNum--) {
  17. scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  18. if (x1 == x2 && y1 == y2)
  19. {
  20. isPass = 0;
  21. }
  22. else {
  23. for (scanf("%d", &planetNum); planetNum > 0; planetNum--) {
  24. scanf("%d %d %d", &X, &Y, &R);
  25.  
  26. if ((double)R > dist(X, Y, x1, y1) || (double)R > dist(X, Y, x2, y2))
  27. {
  28. if ((double)R > dist(X, Y, x1, y1) && (double)R > dist(X, Y, x2, y2))
  29. break;
  30. isPass++;
  31. }
  32.  
  33. }
  34. }
  35. printf("%d\n", isPass);
  36. isPass = 0;
  37. }
  38. }
Success #stdin #stdout 0.01s 5544KB
stdin
1
20 20 50 50
3
20 40 100
30 30 20
15 20 90
stdout
0