klonuj pobierz
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. typedef struct {
  5. int x, y;
  6. } Point;
  7.  
  8. int main() {
  9. int err, n;
  10. scanf("%d", &err);
  11. scanf("%d", &n);
  12.  
  13. Point target, hide_sites[n];
  14. scanf("%d %d", &target.x, &target.y);
  15.  
  16. for (int i = 0; i < n; ++i) {
  17. scanf("%d %d", &hide_sites[i].x, &hide_sites[i].y);
  18. }
  19.  
  20. int closest_torso_index1 = -1, closest_torso_index2 = -1;
  21. int min_torso_error = 99999;
  22.  
  23. for (int i = 0; i < n; ++i) {
  24. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  25. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  26. int error = sqrt(distance_square);
  27.  
  28. if (error <= min_torso_error) {
  29. min_torso_error = error;
  30. closest_torso_index2 = closest_torso_index1;
  31. closest_torso_index1 = i;
  32. }
  33. }
  34.  
  35. int error = 0;
  36. int target_width = 0;
  37.  
  38. if (min_torso_error <= 2000) {
  39. target_width = 35;
  40. }
  41.  
  42. if (target_width > 0) {
  43. error = (target_width * 100) / min_torso_error;
  44. }
  45.  
  46. if (target_width == 35) {
  47. printf("%d %d\n", closest_torso_index1, closest_torso_index2);
  48. } else {
  49. printf("abort\n");
  50. }
  51.  
  52. return 0;
  53. }
  54.  
Sukces #stdin #stdout 0.01s 5380KB
stdin
42
19
-1536 62
-2803 -1364
189 -1937
-477 180
-1149 269
-3396 -135
-1956 -369
-2162 -1531
-2136 488
-2499 -364
-1968 1694
-1586 141
-2018 1667
-2637 1197
-1672 1503
-2039 1104
-3413 1462
-1955 -1061
-76 1155
-1132 1527
stdout
10 3