fork download
  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 min_head_error = 99999;
  21. int head_index = -1;
  22. int min_torso_error = 99999;
  23. int torso_index1 = -1, torso_index2 = -1;
  24.  
  25. for (int i = 0; i < n; ++i) {
  26. int distance_square = (hide_sites[i].x - target.x) * (hide_sites[i].x - target.x) +
  27. (hide_sites[i].y - target.y) * (hide_sites[i].y - target.y);
  28. int error_val = sqrt(distance_square);
  29.  
  30. if (error_val <= min_head_error) {
  31. min_head_error = error_val;
  32. head_index = i;
  33. }
  34.  
  35. if (error_val <= min_torso_error) {
  36. min_torso_error = error_val;
  37. torso_index2 = torso_index1;
  38. torso_index1 = i;
  39. }
  40. }
  41.  
  42. int error_rate = 0;
  43. int target_width = 0;
  44.  
  45. // 计算目标宽度所需的mil数
  46. if (min_head_error <= 1000) {
  47. target_width = 15;
  48. error_rate = (target_width * 100) / min_head_error;
  49. } else if (min_torso_error <= 2000) {
  50. target_width = 35;
  51. error_rate = (target_width * 100) / min_torso_error;
  52. } else {
  53. error_rate = 0;
  54. }
  55.  
  56. if (error_rate >= err) {
  57. printf("abort\n");
  58. } else if (target_width == 15) {
  59. printf("%d\n", head_index);
  60. } else if (target_width == 35) {
  61. printf("%d %d\n", torso_index1, torso_index2);
  62. }
  63.  
  64. return 0;
  65. }
  66.  
Success #stdin #stdout 0s 5476KB
stdin
30
1
-104 5
339 820
stdout
0