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 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_head_error) {
  29. min_head_error = error;
  30. }
  31.  
  32. if (error < min_torso_error) {
  33. min_torso_error = error;
  34. }
  35. }
  36.  
  37. int error = 0;
  38. int target_width = 0;
  39.  
  40. // 计算目标宽度所需的mil数
  41. if (min_head_error <= 1000) {
  42. target_width = 15;
  43. } else if (min_torso_error <= 2000) {
  44. target_width = 35;
  45. }
  46.  
  47. // 计算错误
  48. if (target_width > 0) {
  49. error = (target_width * 100) / min_head_error;
  50. }
  51.  
  52. if (error >= err) {
  53. printf("abort\n");
  54. } else {
  55. printf("abort\n");
  56. }
  57.  
  58. return 0;
  59. }
  60.  
Success #stdin #stdout 0.01s 5512KB
stdin
30
1
-104 5
339 820
stdout
abort