fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int err, n, Tx, Ty;
  6. scanf("%d", &err);
  7. scanf("%d", &n);
  8. scanf("%d %d", &Tx, &Ty);
  9.  
  10. int headHitIndex = -1;
  11. int torsoHitIndex1 = -1;
  12. int torsoHitIndex2 = -1;
  13. int minHeadError = 2000;
  14. int minTorsoError = 2000;
  15.  
  16. for (int i = 0; i < n; ++i) {
  17. int xi, yi;
  18. scanf("%d %d", &xi, &yi);
  19.  
  20. int distanceSquared = (xi - Tx) * (xi - Tx) + (yi - Ty) * (yi - Ty);
  21. int error = sqrt(distanceSquared) * err / 100;
  22.  
  23. if (error <= 15 && (headHitIndex == -1 || error < minHeadError)) {
  24. headHitIndex = i;
  25. minHeadError = error;
  26. } else if (error <= 35) {
  27. if (torsoHitIndex1 == -1 || error < minTorsoError) {
  28. torsoHitIndex2 = torsoHitIndex1;
  29. torsoHitIndex1 = i;
  30. minTorsoError = error;
  31. } else if (torsoHitIndex2 == -1 || error < minTorsoError) {
  32. torsoHitIndex2 = i;
  33. minTorsoError = error;
  34. }
  35. }
  36. }
  37.  
  38. if (headHitIndex != -1) {
  39. printf("%d\n", headHitIndex);
  40. } else if (torsoHitIndex1 != -1 && torsoHitIndex2 != -1) {
  41. printf("%d %d\n", torsoHitIndex1, torsoHitIndex2);
  42. } else {
  43. printf("abort\n");
  44. }
  45.  
  46. return 0;
  47. }
  48.  
Success #stdin #stdout 0s 5376KB
stdin
20
3
0 0
-500 1500
1000 200
3000 1000
stdout
abort