{"id":115,"date":"2026-10-31T17:09:00","date_gmt":"2026-10-31T09:09:00","guid":{"rendered":"https:\/\/blog.sirin.fun\/?p=115"},"modified":"2026-10-31T17:09:01","modified_gmt":"2026-10-31T09:09:01","slug":"acm%e5%88%b7%e9%a2%98%e7%ac%94%e8%ae%b0%ef%bc%88%e5%85%b6%e5%9b%9b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/blog.sirin.fun\/index.php\/2026\/10\/31\/acm%e5%88%b7%e9%a2%98%e7%ac%94%e8%ae%b0%ef%bc%88%e5%85%b6%e5%9b%9b%ef%bc%89\/","title":{"rendered":"acm\u5237\u9898\u7b14\u8bb0\uff08\u5176\u56db\uff09"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>Radar\u00a0Installation\uff08<\/strong><a href=\"http:\/\/acm.hnu.edu.cn\/online\/?action=problem&amp;type=show&amp;id=10023\" target=\"_blank\"  rel=\"nofollow\" >10023<\/a>\uff09<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"515\" src=\"https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437539-1793437539-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-1024x515-1.png\" alt=\"\" class=\"wp-image-116\" srcset=\"https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437539-1793437539-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-1024x515-1.png 1024w, https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437539-1793437539-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-300x151-1.png 300w, https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437539-1793437539-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-767x386-1.png 767w, https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437539-1793437539-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-1536x773-1.png 1536w, https:\/\/blog.sirin.fun\/wp-content\/uploads\/2026\/10\/1793437540-1793437540-1793437534-1793437534-33B1893C-6FFC-4D0E-9A43-DDC579C0DCAB-2048x1030-1.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b8c\u5168\u6ca1\u601d\u8def\uff0c\u5bf9\u5427\uff1f<\/p>\n\n\n\n<pre><code class=\"language-cpp\">#include&lt;iostream&gt;\n#include&lt;vector&gt;\n#include&lt;cmath&gt;\n#include&lt;algorithm&gt;\n\nusing namespace std;\ntypedef pair&lt;int,int&gt; position;\nstruct input_type{\n\tvector&lt;position&gt; poss;\n\tint n,d;\n\tbool isend;\n};\n\ninline input_type handle_input();\ninline bool compare(position a, position b){\n\treturn a.first&lt;b.first;\n}\ninline bool compare1(pair&lt;double,double&gt; a, pair&lt;double,double&gt; b){\n\treturn a.second&lt;b.second;\n}\nint main(){\n\tvector&lt;int&gt; ans;\n\twhile(1){\n\t\tinput_type input =handle_input();\n\t\tif(input.isend)\n\t\t\tbreak;\n\t\t\n\t\tvector&lt;pair&lt;double,double&gt; &gt; lines;\/\/start,end \n\t\tvector&lt;double&gt; poss_x;\n\t\t\t\t\n\t\tfor(int i=0;i&lt;input.poss.size();i++){\n\t\t\n\t\t\tif(input.poss[i].second&gt;input.d){\n\t\t\t\tans.push_back(-1);\n\t\t\t\tgoto END;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdouble x,y;\n\t\t\tx=input.poss[i].first;\n\t\t\ty=input.poss[i].second;\n\t\t\tint d = input.d;\n\t\t\t\/*\n\t\t\t*\u5c06\u5c9b\u6295\u5f71\u5230\u6d77\u5cb8\u7ebf\u4e0a\uff0c\u628a\u5c9b\u8f6c\u5316\u4e3a\u4e00\u4e2a\u7ebf\u6bb5\n\t\t\t*\u5bf9\u4e8ey\uff08y&lt;d\uff09\u7684\u5c9b\uff0c\u96f7\u8fbe\u843d\u5728x-(d^2-y^2)^0.5\u5230x+(d^2-y^2)^0.5\u7684\u8303\u56f4\u5373\u53ef\n\t\t\t*\u5c31\u662f\u8bf4\u5c06\u96f7\u8fbe\u627e\u5c9b\u8f6c\u5316\u4e3a\u5c9b\u627e\u96f7\u8fbe\n\t\t\t*\/\n\t\t\tpair&lt;double,double&gt; line;\n\t\t\tline.first = (x-sqrt(d*d-y*y));\n\t\t\tline.second = (x+sqrt(d*d-y*y));\n\t\t\tlines.push_back(line);\n\n\t\t}\n\t\tsort(lines.begin(),lines.end(),compare1);\n\t\t\n\t\tfor(int i=0;i&lt;lines.size();i++){\n\t\t\tpair&lt;double,double&gt; line = lines[i];\n\t\t\t\t\t\t\n\t\t\tif(i==0){\n\t\t\t\tposs_x.push_back(line.second);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tdouble pos_x_before = poss_x.back();\n\n\t\t\tif(line.first&lt;=pos_x_before&amp;&amp;line.second&gt;=pos_x_before){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t\n\t\t\tposs_x.push_back(line.second);\n\t\t}\n\t\tans.push_back(poss_x.size());\n\t\tEND:;\n\t\t\/\/ciallo\n\t}\n\t\n\tfor(int i=0;i&lt;ans.size();i++){\n\t\tcout&lt;&lt;\"Case \"&lt;&lt;i+1&lt;&lt;\": \"&lt;&lt;ans[i]&lt;&lt;\"\\n\";\n\t}\n}\ninput_type handle_input(){\n\t\/*\n\tThe input consists of several test cases. \n\tThe first line of each case contains two integers n (1&lt;=n&lt;=1000) and d,\n\twhere n is the number of islands in the sea and d is the distance of coverage of the radar installation. \n\tThis is followed by n lines each containing two integers representing \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tthe coordinate of the position of each island. \n\tThen a blank line follows to separate the cases.\n\t*\/\n\tinput_type tmp;\n\tcin&gt;&gt;tmp.n&gt;&gt;tmp.d;\n\tif(tmp.n==0&amp;&amp;tmp.d==0){\n\t\ttmp.isend = true;\n\t\treturn tmp;\n\t}\n\tfor(int i=0;i&lt;tmp.n;i++){\n\t\tint tmp_a,tmp_b;\n\t\tif(cin&gt;&gt;tmp_a&gt;&gt;tmp_b){\n\t\t\ttmp.isend = false;\n\t\t\ttmp.poss.push_back(position(tmp_a,tmp_b));\n\t\t}else{\n\t\t\tbreak;\n\t\t}\n\t}\t\t\t\n\tsort(tmp.poss.begin(),tmp.poss.end(),compare);\n\t\/\/\u8f93\u5165\u7684\u5c9b\u5c7f\u4e0d\u662f\u6709\u5e8f\u7684\uff0c\u6839\u636ex\u5750\u6807\u6392\u5e8f\n\treturn tmp;\n}<\/code><\/pre>\n\n\n\n<div style=\"font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; font-size: 16px; line-height: 1.8; color: #24292f; max-width: 860px; margin: 0 auto; background: #ffffff; padding: 24px; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.06);\">\n\n    <p style=\"font-size: 17px; color: #0969da; font-weight: bold; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid #e1e4e8;\">\n        \u7406\u89e3\u8fd9\u9053\u9898\u7684\u6838\u5fc3\uff0c\u9700\u8981\u5148\u540e\u5b8c\u6210\u4e09\u6b21\u601d\u7ef4\u8f6c\u6362\uff1a\u9996\u5148\u8bf4\u660e\u4e3a\u4ec0\u4e48\u4f60\u539f\u672c\u7684\u76f4\u89c9\u60f3\u6cd5\u4e0d\u53ef\u884c\uff0c\u5176\u6b21\u628a\u4e8c\u7ef4\u7684\u6d77\u5c9b\u95ee\u9898\u62cd\u6241\u6210\u4e00\u7ef4\u7684\u7ebf\u6bb5\u95ee\u9898\uff0c\u6700\u540e\u7528\u6b63\u786e\u7684\u8d2a\u5fc3\u89c4\u5219\u628a\u96f7\u8fbe\u4e00\u9897\u9897\u5b9a\u4e0b\u6765\u3002\n    <\/p>\n\n    <!-- \u7b2c\u4e00\u6b65 -->\n    <div style=\"margin-bottom: 36px;\">\n        <h3 style=\"font-size: 19px; color: #cf222e; margin-bottom: 16px; display: flex; align-items: center;\">\n            <span style=\"display: inline-flex; justify-content: center; align-items: center; width: 28px; height: 28px; background: #cf222e; color: white; border-radius: 6px; font-size: 16px; margin-right: 10px;\">1<\/span>\n            \u4e3a\u4ec0\u4e48\u201c\u6bcf\u6b21\u6311\u8986\u76d6\u6700\u591a\u5c9b\u5c7f\u7684\u4f4d\u7f6e\u201d\u4f1a\u51fa\u9519\uff1f\n        <\/h3>\n        <p>\u4f60\u7684\u7b2c\u4e00\u76f4\u89c9\u5f88\u81ea\u7136\uff1a\u627e\u4e00\u4e2a\u80fd\u540c\u65f6\u5708\u4f4f\u6700\u591a\u5c9b\u5c7f\u7684\u5730\u65b9\u653e\u7b2c\u4e00\u5ea7\u96f7\u8fbe\uff0c\u7136\u540e\u518d\u5904\u7406\u5269\u4e0b\u7684\u3002\u4f46\u5728\u7b97\u6cd5\u9898\u91cc\uff0c\u8fd9\u79cd\u8d2a\u5fc3\u662f<strong>\u9519\u8bef<\/strong>\u7684\u3002<\/p>\n        <p>\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u6765\u63a8\u7ffb\u5b83\uff1a\u5047\u8bbe\u6d77\u9762\u4e0a\u4ece\u5de6\u5230\u53f3\u6709 <strong>4 \u5ea7\u5c9b\u5c7f\uff1aA\u3001B\u3001C\u3001D<\/strong>\u3002<\/p>\n        <ul style=\"padding-left: 20px; margin-bottom: 16px; color: #444;\">\n            <li style=\"margin-bottom: 8px;\">A \u548c B \u9760\u5f97\u6bd4\u8f83\u8fd1\uff0c<strong>1 \u5ea7\u96f7\u8fbe<\/strong>\u5c31\u80fd\u540c\u65f6\u8986\u76d6 A \u548c B\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\">C \u548c D \u9760\u5f97\u4e5f\u6bd4\u8f83\u8fd1\uff0c<strong>1 \u5ea7\u96f7\u8fbe<\/strong>\u5c31\u80fd\u540c\u65f6\u8986\u76d6 C \u548c D\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\">\u51d1\u5de7\u7684\u662f\uff0cB\u3001C \u548c A \u79bb\u5f97\u4e5f\u4e0d\u7b97\u592a\u8fdc\uff0c\u5982\u679c\u5728 B \u548c C \u4e2d\u95f4\u67d0\u4e2a\u7279\u5b9a\u4f4d\u7f6e\u653e\u4e00\u5ea7\u96f7\u8fbe\uff0c\u521a\u597d\u80fd\u540c\u65f6\u8986\u76d6 <strong>A\u3001B\u3001C \u4e09\u5ea7\u5c9b<\/strong>\u3002\u66f4\u5178\u578b\u7684\u60c5\u51b5\u662f\uff1a\u5047\u8bbe <strong>B \u548c C \u9760\u5f97\u6781\u8fd1<\/strong>\uff0c\u4e2d\u95f4\u6709 3 \u5ea7\u5c9b\u6324\u5728\u4e00\u8d77\uff0c\u5de6\u53f3\u4e24\u8fb9\u5404 1 \u5ea7\u5c9b\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u6309\u4f60\u7684\u76f4\u89c9<\/strong>\uff1a\u4e2d\u95f4\u90a3\u4e00\u64ae\u6709 3 \u5ea7\u5c9b\uff08B1, B2, C\uff09\uff0c\u628a\u7b2c\u4e00\u5ea7\u96f7\u8fbe\u653e\u5728\u6b63\u4e2d\u95f4\uff0c\u4e00\u53e3\u6c14\u5e72\u6389 3 \u5ea7\u5c9b\uff01\u4f46\u540e\u679c\u662f\uff1a\u6700\u5de6\u8fb9\u7684 A \u591f\u4e0d\u7740\uff0c\u6700\u53f3\u8fb9\u7684 D \u4e5f\u591f\u4e0d\u7740\u3002\u4e3a\u4e86\u6551 A \u548c D\uff0c\u4f60\u8fd8\u5f97\u5728\u5de6\u8fb9\u8865 1 \u5ea7\u3001\u53f3\u8fb9\u8865 1 \u5ea7\uff0c<strong>\u603b\u5171\u82b1\u4e86 3 \u5ea7\u96f7\u8fbe<\/strong>\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u5b9e\u9645\u4e0a\u5462<\/strong>\uff1a\u5982\u679c\u4f60\u514b\u5236\u4f4f\u8bf1\u60d1\uff0c\u7b2c\u4e00\u5ea7\u96f7\u8fbe\u504f\u5de6\u4e00\u70b9\uff0c\u8986\u76d6 A\u3001B1\u3001B2\uff1b\u7b2c\u4e8c\u5ea7\u96f7\u8fbe\u504f\u53f3\u4e00\u70b9\uff0c\u8986\u76d6 C\u3001D\u3002<strong>\u603b\u5171\u53ea\u9700\u8981 2 \u5ea7\u96f7\u8fbe\uff01<\/strong><\/li>\n        <\/ul>\n        <div style=\"background: #fff8c5; border-left: 4px solid #d4a72c; padding: 12px 16px; border-radius: 0 6px 6px 0; color: #6b5900; font-size: 15px;\">\n            <strong>\u7ed3\u8bba\uff1a<\/strong>\u8d2a\u56fe\u4e00\u65f6\u201c\u5403\u5f97\u6700\u591a\u201d\uff0c\u5f80\u5f80\u4f1a\u628a\u4e24\u8fb9\u7684\u96f6\u6563\u5c9b\u5c7f\u5b64\u7acb\u51fa\u6765\uff0c\u5bfc\u81f4\u6574\u4f53\u6d6a\u8d39\u3002\u6b63\u786e\u7684\u8d2a\u5fc3\u4e0d\u5e94\u8be5\u4ece\u201c\u4e2d\u95f4\u6700\u5bc6\u96c6\u7684\u5730\u65b9\u201d\u4e0b\u624b\uff0c\u800c\u5e94\u8be5<strong>\u4ece\u4e00\u7aef\uff08\u6bd4\u5982\u6700\u5de6\u8fb9\uff09\u5f00\u59cb\uff0c\u6309\u987a\u5e8f\u4e00\u4e2a\u4e2a\u89e3\u51b3\uff0c\u4e0d\u7559\u6b7b\u89d2<\/strong>\u3002\n        <\/div>\n    <\/div>\n\n    <!-- \u7b2c\u4e8c\u6b65 -->\n    <div style=\"margin-bottom: 36px;\">\n        <h3 style=\"font-size: 19px; color: #0969da; margin-bottom: 16px; display: flex; align-items: center;\">\n            <span style=\"display: inline-flex; justify-content: center; align-items: center; width: 28px; height: 28px; background: #0969da; color: white; border-radius: 6px; font-size: 16px; margin-right: 10px;\">2<\/span>\n            \u964d\u7ef4\u6253\u51fb\u2014\u2014\u4ece\u201c\u96f7\u8fbe\u627e\u5c9b\u201d\u53d8\u6210\u201c\u5c9b\u627e\u96f7\u8fbe\u201d\n        <\/h3>\n        <p>\u9898\u76ee\u4e2d\u5c9b\u5c7f\u5728\u4e8c\u7ef4\u6d77\u9762\u4e0a\uff0c\u96f7\u8fbe\u5728\u4e00\u7ef4\u6d77\u5cb8\u7ebf\uff08x \u8f74\uff09\u4e0a\u3002\u5982\u679c\u7ad9\u5728\u96f7\u8fbe\u7684\u89c6\u89d2\u53bb\u51d1\u5c9b\u5c7f\uff0c\u4e8c\u7ef4\u7a7a\u95f4\u7b97\u8d77\u6765\u975e\u5e38\u9ebb\u70e6\u3002\u6211\u4eec\u8981\u53cd\u8fc7\u6765\u60f3\uff1a<strong>\u7ad9\u5728\u6bcf\u4e00\u5ea7\u5c9b\u5c7f\u7684\u89c6\u89d2\uff0c\u53bb\u8981\u6c42\u96f7\u8fbe<\/strong>\u3002<\/p>\n        \n        <p><strong>1. \u5355\u5ea7\u5c9b\u5c7f\u7684\u5e95\u7ebf\uff1a<\/strong>\u62ce\u51fa\u4efb\u610f\u4e00\u5ea7\u5c9b\u5c7f\uff0c\u5b83\u7684\u5750\u6807\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">(x, y)<\/span>\u3002\u96f7\u8fbe\u7684\u6700\u5927\u8986\u76d6\u534a\u5f84\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d<\/span>\u3002\u8fd9\u5c31\u50cf\u5728\u8fd9\u5ea7\u5c9b\u5c7f\u4e0a\u6813\u4e86\u4e00\u6839\u957f\u5ea6\u4e3a <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d<\/span> \u7684\u7ef3\u5b50\uff0c\u62ff\u7740\u7ef3\u5b50\u7684\u53e6\u4e00\u5934\u53bb\u591f x \u8f74\u3002<\/p>\n        <ul style=\"padding-left: 20px; margin-bottom: 16px; color: #444;\">\n            <li style=\"margin-bottom: 8px;\"><strong>\u591f\u4e0d\u7740\u7684\u60c5\u51b5\uff1a<\/strong>\u5982\u679c\u8fd9\u5ea7\u5c9b\u79bb\u6d77\u5cb8\u7ebf\u7684\u5782\u76f4\u8ddd\u79bb <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y<\/span> \u6bd4\u7ef3\u5b50\u957f\u5ea6 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d<\/span> \u8fd8\u8981\u957f\uff08\u5373 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y &gt; d<\/span>\uff09\uff0c\u90a3\u795e\u4ed9\u4e5f\u6551\u4e0d\u4e86\u5b83\uff0c\u7ef3\u5b50\u6839\u672c\u78b0\u4e0d\u5230\u6d77\u5cb8\u7ebf\u3002\u4e00\u65e6\u53d1\u73b0\u4efb\u4f55\u4e00\u5ea7\u5c9b\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\uff0c\u6574\u9053\u9898\u76f4\u63a5\u5ba3\u544a\u65e0\u89e3\uff0c\u8f93\u51fa <code style=\"background: #f6f8fa; padding: 2px 6px; border-radius: 4px;\">-1<\/code>\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u591f\u5f97\u7740\u7684\u60c5\u51b5\uff1a<\/strong>\u5982\u679c <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y &le; d<\/span>\uff0c\u4f60\u62ff\u7740\u7ef3\u5b50\u5934\u5728\u6d77\u5cb8\u7ebf\u4e0a\u5f80\u5de6\u62c9\u5230\u5e95\uff0c\u80fd\u78b0\u5230 x \u8f74\u4e0a\u7684\u4e00\u4e2a\u6700\u5de6\u70b9\uff1b\u5f80\u53f3\u62c9\u5230\u5e95\uff0c\u80fd\u78b0\u5230 x \u8f74\u4e0a\u7684\u4e00\u4e2a\u6700\u53f3\u70b9\u3002\u6839\u636e\u52fe\u80a1\u5b9a\u7406\uff08\u659c\u8fb9\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d<\/span>\uff0c\u76f4\u89d2\u8fb9\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y<\/span>\uff09\uff0c\u53e6\u4e00\u6761\u8d34\u7740 x \u8f74\u7684\u76f4\u89d2\u8fb9\u957f\u5ea6\u5c31\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">&radic;(d<sup>2<\/sup> - y<sup>2<\/sup>)<\/span>\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\">\u6240\u4ee5\uff0c\u4e3a\u4e86\u8ba9\u8fd9\u5ea7\u5c9b\u88ab\u8986\u76d6\uff0c\u96f7\u8fbe<strong>\u5fc5\u987b<\/strong>\u4fee\u5728 x \u8f74\u4e0a\u4ece <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">x - &radic;(d<sup>2<\/sup> - y<sup>2<\/sup>)<\/span> \u5230 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">x + &radic;(d<sup>2<\/sup> - y<sup>2<\/sup>)<\/span> \u8fd9\u6bb5\u8303\u56f4\u5185\u3002<\/li>\n        <\/ul>\n\n        <p><strong>2. \u6d77\u5c9b\u6d88\u5931\uff0c\u53d8\u6210\u7ebf\u6bb5\uff1a<\/strong>\u5bf9\u6bcf\u4e00\u5ea7\u5c9b\u90fd\u505a\u4e0a\u9762\u7684\u8ba1\u7b97\u540e\uff0c\u6d77\u9762\u4e0a\u7684 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">n<\/span> \u5ea7\u5c9b\u5c7f\u5c31\u5168\u90e8\u6d88\u5931\u4e86\uff0c\u53d6\u800c\u4ee3\u4e4b\u7684\u662f\u8d34\u5728 x \u8f74\u4e0a\u7684 <strong><span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">n<\/span> \u6761\u957f\u77ed\u4e0d\u4e00\u3001\u4e92\u76f8\u91cd\u53e0\u7684\u7ebf\u6bb5\uff08\u533a\u95f4\uff09<\/strong>\u3002<\/p>\n        <p>\u73b0\u5728\uff0c\u9898\u76ee\u5f7b\u5e95\u53d8\u6210\u4e86\uff1a<strong>x \u8f74\u4e0a\u8eba\u7740 n \u6761\u7ebf\u6bb5\uff0c\u4f60\u624b\u91cc\u6709\u51e0\u9897\u56fe\u9489\uff08\u96f7\u8fbe\uff09\uff0c\u6700\u5c11\u624e\u51e0\u9897\u56fe\u9489\uff0c\u80fd\u628a\u6240\u6709\u7ebf\u6bb5\u90fd\u56fa\u5b9a\u4f4f\uff08\u6bcf\u6761\u7ebf\u6bb5\u4e0a\u81f3\u5c11\u6709\u4e00\u9897\u56fe\u9489\uff09\uff1f<\/strong><\/p>\n    <\/div>\n\n    <!-- \u7b2c\u4e09\u6b65 -->\n    <div style=\"margin-bottom: 36px;\">\n        <h3 style=\"font-size: 19px; color: #0969da; margin-bottom: 16px; display: flex; align-items: center;\">\n            <span style=\"display: inline-flex; justify-content: center; align-items: center; width: 28px; height: 28px; background: #0969da; color: white; border-radius: 6px; font-size: 16px; margin-right: 10px;\">3<\/span>\n            \u6838\u5fc3\u8d2a\u5fc3\u7b56\u7565\u2014\u2014\u201c\u6b7b\u7ebf\uff08Deadline\uff09\u4f18\u5148\u201d\u4e0e\u201c\u6781\u9650\u62d6\u5ef6\u201d\n        <\/h3>\n        <p>\u600e\u4e48\u624e\u56fe\u9489\u6700\u7701\uff1f\u4f60\u53ef\u4ee5\u628a\u6bcf\u4e00\u6761\u7ebf\u6bb5\u60f3\u8c61\u6210\u8001\u677f\u5e03\u7f6e\u7ed9\u4f60\u7684\u4e00\u4e2a\u4efb\u52a1\uff1a<strong>\u7ebf\u6bb5\u7684\u5de6\u7aef\u70b9\u662f\u201c\u4efb\u52a1\u5f00\u59cb\u65f6\u95f4\u201d\uff0c\u53f3\u7aef\u70b9\u662f\u201c\u4efb\u52a1\u622a\u6b62\u65f6\u95f4\uff08Deadline\uff09\u201d<\/strong>\u3002\u624e\u4e00\u9897\u56fe\u9489\uff0c\u5c31\u76f8\u5f53\u4e8e\u4f60\u6311\u4e86\u4e00\u4e2a\u65f6\u95f4\u70b9\u53bb\u5e72\u6d3b\uff0c\u53ea\u8981\u8fd9\u4e2a\u65f6\u95f4\u70b9\u843d\u5728\u67d0\u51e0\u4e2a\u4efb\u52a1\u7684\u65f6\u95f4\u6bb5\u5185\uff0c\u8fd9\u51e0\u4e2a\u4efb\u52a1\u5c31\u540c\u65f6\u88ab\u5b8c\u6210\u4e86\u3002<\/p>\n\n        <h4 style=\"font-size: 16px; color: #24292f; margin-top: 20px; margin-bottom: 10px;\">1. \u4e3a\u4ec0\u4e48\u8981\u6309\u201c\u53f3\u7aef\u70b9\uff08Deadline\uff09\u201d\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\uff1f<\/h4>\n        <p>\u9762\u5bf9\u4e00\u5806\u4efb\u52a1\uff0c\u4f60\u80af\u5b9a\u8981\u5148\u770b<strong>\u54ea\u4e2a\u4efb\u52a1\u7684\u622a\u6b62\u65f6\u95f4\uff08\u53f3\u7aef\u70b9\uff09\u6700\u65e9<\/strong>\u3002\u627e\u5230\u5168\u56fe\u53f3\u7aef\u70b9\u6700\u9760\u5de6\u7684\u90a3\u6761\u7ebf\u6bb5\uff08\u6211\u4eec\u53eb\u5b83\u201c1 \u53f7\u7ebf\u6bb5\u201d\uff09\u3002\u5b83\u7684\u53f3\u7aef\u70b9\uff0c\u662f\u6240\u6709\u7ebf\u6bb5\u91cc\u6700\u65e9\u7ed3\u675f\u7684\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5728\u5b83\u7684\u53f3\u7aef\u70b9\u4e4b\u524d\uff0c\u4f60<strong>\u65e0\u8bba\u5982\u4f55\u90fd\u5fc5\u987b\u624e\u4e0b\u7b2c\u4e00\u9897\u56fe\u9489<\/strong>\uff0c\u5426\u5219 1 \u53f7\u7ebf\u6bb5\u5c31\u6c38\u8fdc\u9519\u8fc7\u4e86\uff01<\/p>\n\n        <h4 style=\"font-size: 16px; color: #24292f; margin-top: 20px; margin-bottom: 10px;\">2. \u7b2c\u4e00\u9897\u56fe\u9489\u624e\u5728\u54ea\u91cc\u6700\u5212\u7b97\uff1f<\/h4>\n        <p>\u65e2\u7136\u5fc5\u987b\u5728 1 \u53f7\u7ebf\u6bb5\u7684\u8303\u56f4\u5185\u624e\u7b2c\u4e00\u9897\u56fe\u9489\uff0c\u624e\u5728\u5b83\u7684\u5de6\u8fb9\u3001\u4e2d\u95f4\u3001\u8fd8\u662f\u6700\u53f3\u8fb9\u597d\uff1f<\/p>\n        <p>\u7b54\u6848\u662f\uff1a<strong>\u6b7b\u6b7b\u5361\u5728 1 \u53f7\u7ebf\u6bb5\u7684\u201c\u6700\u53f3\u7aef\u70b9\u201d\u624e\u4e0b\u53bb\uff01<\/strong><\/p>\n        <p>\u4e3a\u4ec0\u4e48\uff1f\u56e0\u4e3a 1 \u53f7\u7ebf\u6bb5\u662f\u6240\u6709\u7ebf\u6bb5\u91cc\u6700\u65e9\u7ed3\u675f\u7684\uff0c\u5176\u4ed6\u6240\u6709\u7ebf\u6bb5\u7684\u7ed3\u675f\u65f6\u95f4\u90fd\u6bd4\u5b83\u66f4\u9760\u53f3\u3002\u4f60\u628a\u56fe\u9489\u624e\u5728 1 \u53f7\u7ebf\u6bb5\u7684\u6700\u53f3\u7aef\uff0c\u9996\u5148\u4fdd\u8bc1\u4e86 1 \u53f7\u7ebf\u6bb5\u80af\u5b9a\u88ab\u624e\u4e2d\uff1b\u540c\u65f6\uff0c\u56e0\u4e3a\u4f60<strong>\u5c3d\u53ef\u80fd\u5730\u5f80\u53f3\u9760\u4e86<\/strong>\uff0c\u8fd9\u9897\u56fe\u9489\u5c31\u6709\u4e86\u6700\u5927\u7684\u673a\u4f1a\u53bb\u591f\u5230\u540e\u9762\u90a3\u4e9b\u8fd8\u6ca1\u7ed3\u675f\u7684\u7ebf\u6bb5\uff01\u8fd9\u5c31\u53eb\u201c\u6781\u9650\u62d6\u5ef6\uff0c\u4e00\u7bad\u591a\u96d5\u201d\u3002<\/p>\n\n        <h4 style=\"font-size: 16px; color: #24292f; margin-top: 20px; margin-bottom: 10px;\">3. \u987a\u85e4\u6478\u74dc\u5904\u7406\u5269\u4e0b\u7684\u7ebf\u6bb5<\/h4>\n        <p>\u628a\u6240\u6709\u7ebf\u6bb5\u6309\u7167<strong>\u53f3\u7aef\u70b9\u4ece\u5de6\u5230\u53f3<\/strong>\u6392\u597d\u961f\u540e\uff0c\u6e38\u620f\u6b63\u5f0f\u5f00\u59cb\uff1a<\/p>\n        <ol style=\"padding-left: 20px; margin-bottom: 16px; color: #444;\">\n            <li style=\"margin-bottom: 8px;\"><strong>\u624e\u7b2c\u4e00\u9897\u9489\u5b50\uff1a<\/strong>\u770b\u7740\u6392\u5728\u7b2c\u4e00\u4f4d\u7684 1 \u53f7\u7ebf\u6bb5\uff0c\u76f4\u63a5\u628a\u7b2c 1 \u9897\u56fe\u9489\u624e\u5728\u5b83\u7684<strong>\u6700\u53f3\u7aef<\/strong>\u3002\u8bb0\u5f55\u4e0b\u8fd9\u9897\u56fe\u9489\u7684\u4f4d\u7f6e\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u68c0\u67e5 2 \u53f7\u7ebf\u6bb5\uff1a<\/strong>\u770b\u6392\u5728\u7b2c\u4e8c\u4f4d\u7684\u7ebf\u6bb5\uff0c\u5b83\u80fd\u4e0d\u80fd\u8e6d\u5230\u521a\u624d\u90a3\u9897\u56fe\u9489\uff1f<br>\u56e0\u4e3a\u6211\u4eec\u662f\u6309\u53f3\u7aef\u70b9\u6392\u7684\u961f\uff0c\u6240\u4ee5 2 \u53f7\u7ebf\u6bb5\u7684<strong>\u53f3\u7aef\u70b9<\/strong>\u80af\u5b9a\u5728\u56fe\u9489\u7684\u53f3\u8fb9\uff08\u6216\u8005\u91cd\u5408\uff09\u3002\u90a3\u4e48 2 \u53f7\u7ebf\u6bb5\u80fd\u4e0d\u80fd\u88ab\u624e\u4e2d\uff0c\u53ea\u53d6\u51b3\u4e8e\u5b83\u7684<strong>\u5de6\u7aef\u70b9<\/strong>\uff01<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u60c5\u51b5 A\uff08\u80fd\u8e6d\u5230\uff09\uff1a<\/strong>\u5982\u679c 2 \u53f7\u7ebf\u6bb5\u7684<strong>\u5de6\u7aef\u70b9<\/strong>\u5728\u56fe\u9489\u7684\u5de6\u8fb9\uff08\u6216\u8005\u6b63\u597d\u5728\u56fe\u9489\u4e0a\uff09\uff0c\u8bf4\u660e 2 \u53f7\u7ebf\u6bb5\u6a2a\u8de8\u4e86\u8fd9\u9897\u56fe\u9489\uff01\u592a\u68d2\u4e86\uff0c2 \u53f7\u5c9b\u5c7f\u514d\u8d39\u767d\u5ad6\u4e86\u8fd9\u9897\u96f7\u8fbe\uff0c\u4ec0\u4e48\u90fd\u4e0d\u7528\u505a\uff0c\u76f4\u63a5\u770b 3 \u53f7\u7ebf\u6bb5\u3002<\/li>\n            <li style=\"margin-bottom: 8px;\"><strong>\u60c5\u51b5 B\uff08\u8e6d\u4e0d\u5230\uff09\uff1a<\/strong>\u5982\u679c 2 \u53f7\u7ebf\u6bb5\u7684<strong>\u5de6\u7aef\u70b9<\/strong>\u5df2\u7ecf\u5728\u56fe\u9489\u7684\u53f3\u8fb9\u4e86\uff0c\u8bf4\u660e 2 \u53f7\u7ebf\u6bb5\u6574\u6761\u90fd\u5728\u56fe\u9489\u7684\u53f3\u4fa7\uff0c\u521a\u624d\u90a3\u9897\u56fe\u9489\u5f7b\u5e95\u591f\u4e0d\u7740\u5b83\u4e86\u3002\u6b64\u65f6\u9488\u5bf9\u8fd9\u4e2a\u8e6d\u4e0d\u5230\u7684\u65b0\u7ebf\u6bb5\uff0c\u91cd\u6f14\u521a\u624d\u7684\u903b\u8f91\u2014\u2014\u62ff\u51fa\u4e00\u9897\u65b0\u56fe\u9489\uff0c\u6b7b\u6b7b\u624e\u5728\u8fd9\u4e2a\u65b0\u7ebf\u6bb5\u7684<strong>\u6700\u53f3\u7aef\u70b9<\/strong>\u4e0a\uff01\u7136\u540e\u7528\u8fd9\u9897\u65b0\u56fe\u9489\u7684\u4f4d\u7f6e\uff0c\u7ee7\u7eed\u5f80\u540e\u68c0\u67e5\u540e\u9762\u7684\u7ebf\u6bb5\u3002<\/li>\n        <\/ol>\n    <\/div>\n\n    <!-- \u7b2c\u56db\u6b65 -->\n    <div style=\"margin-bottom: 24px;\">\n        <h3 style=\"font-size: 19px; color: #1a7f37; margin-bottom: 16px; display: flex; align-items: center;\">\n            <span style=\"display: inline-flex; justify-content: center; align-items: center; width: 28px; height: 28px; background: #1a7f37; color: white; border-radius: 6px; font-size: 16px; margin-right: 10px;\">4<\/span>\n            \u7528\u9898\u76ee\u7ed9\u7684 Sample 1 \u8d70\u4e00\u904d\u5168\u6d41\u7a0b\n        <\/h3>\n        <p>\u9898\u76ee\u7b2c\u4e00\u4e2a\u6837\u4f8b\uff1a<span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">n = 3<\/span>\uff083 \u5ea7\u5c9b\uff09\uff0c<span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d = 2<\/span>\uff08\u96f7\u8fbe\u534a\u5f84\u4e3a 2\uff09\u3002\u4e09\u5ea7\u5c9b\u7684\u5750\u6807\u5206\u522b\u662f\uff1a<code>A(1, 2)<\/code>\u3001<code>B(-3, 1)<\/code>\u3001<code>C(2, 1)<\/code>\u3002<\/p>\n\n        <div style=\"background: #f6f8fa; border: 1px solid #e1e4e8; border-radius: 8px; padding: 16px; margin-bottom: 16px;\">\n            <p style=\"margin-top: 0;\"><strong>1. \u8f6c\u5316\u4e3a x \u8f74\u4e0a\u7684\u7ebf\u6bb5\uff1a<\/strong><\/p>\n            <ul style=\"padding-left: 20px; margin-bottom: 0; color: #444;\">\n                <li style=\"margin-bottom: 8px;\"><strong>\u5c9b A (1, 2)\uff1a<\/strong>\u79bb\u6d77\u5cb8\u7ebf\u8ddd\u79bb <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y = 2<\/span>\uff0c\u6b63\u597d\u7b49\u4e8e\u534a\u5f84 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">d = 2<\/span>\u3002\u7b97\u51fa\u5de6\u53f3\u504f\u79fb\u91cf <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">&radic;(2<sup>2<\/sup> - 2<sup>2<\/sup>) = 0<\/span>\u3002\u6240\u4ee5\u5b83\u7684\u7ebf\u6bb5\u662f <strong>[1, 1]<\/strong>\uff08\u4e00\u4e2a\u70b9\uff0c\u96f7\u8fbe\u5fc5\u987b\u7cbe\u51c6\u653e\u5728 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">x = 1<\/span> \u624d\u80fd\u6551\u5b83\uff09\u3002<\/li>\n                <li style=\"margin-bottom: 8px;\"><strong>\u5c9b B (-3, 1)\uff1a<\/strong><span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y = 1<\/span>\uff0c\u504f\u79fb\u91cf <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">&radic;(2<sup>2<\/sup> - 1<sup>2<\/sup>) = &radic;3 &asymp; 1.732<\/span>\u3002\u5b83\u7684\u7ebf\u6bb5\u662f <strong>[-4.732, -1.268]<\/strong>\u3002<\/li>\n                <li style=\"margin-bottom: 8px;\"><strong>\u5c9b C (2, 1)\uff1a<\/strong><span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">y = 1<\/span>\uff0c\u504f\u79fb\u91cf\u540c\u6837\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">1.732<\/span>\u3002\u5b83\u7684\u7ebf\u6bb5\u662f <strong>[0.268, 3.732]<\/strong>\u3002<\/li>\n            <\/ul>\n        <\/div>\n\n        <div style=\"background: #f6f8fa; border: 1px solid #e1e4e8; border-radius: 8px; padding: 16px; margin-bottom: 16px;\">\n            <p style=\"margin-top: 0;\"><strong>2. \u6309\u53f3\u7aef\u70b9\u4ece\u5c0f\u5230\u5927\u6392\u961f\uff1a<\/strong><\/p>\n            <p style=\"margin-bottom: 0; color: #444;\">\u6bd4\u8f83\u4e09\u6761\u7ebf\u6bb5\u7684\u53f3\u7aef\u70b9\uff1a<span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">-1.268 &lt; 1 &lt; 3.732<\/span>\u3002\u6392\u961f\u540e\u7684\u987a\u5e8f\u662f\uff1a<br>\n            \u7b2c 1 \u540d\uff1a\u5c9b B \u7684\u7ebf\u6bb5 <strong>[-4.732, -1.268]<\/strong><br>\n            \u7b2c 2 \u540d\uff1a\u5c9b A \u7684\u7ebf\u6bb5 <strong>[1, 1]<\/strong><br>\n            \u7b2c 3 \u540d\uff1a\u5c9b C \u7684\u7ebf\u6bb5 <strong>[0.268, 3.732]<\/strong><\/p>\n        <\/div>\n\n        <div style=\"background: #f6f8fa; border: 1px solid #e1e4e8; border-radius: 8px; padding: 16px;\">\n            <p style=\"margin-top: 0;\"><strong>3. \u5f00\u59cb\u624e\u56fe\u9489\uff08\u653e\u96f7\u8fbe\uff09\uff1a<\/strong><\/p>\n            <ul style=\"padding-left: 20px; margin-bottom: 0; color: #444;\">\n                <li style=\"margin-bottom: 8px;\"><strong>\u770b\u7b2c 1 \u540d\uff08\u5c9b B\uff09\uff1a<\/strong>\u5fc5\u987b\u6551\u5b83\uff0c\u628a\u7b2c 1 \u5ea7\u96f7\u8fbe\u653e\u5728\u5b83\u7684\u6700\u53f3\u7aef <strong>-1.268<\/strong> \u5904\u3002\uff08\u5f53\u524d\u96f7\u8fbe\u6570 = 1\uff0c\u5f53\u524d\u96f7\u8fbe\u4f4d\u7f6e = -1.268\uff09\u3002<\/li>\n                <li style=\"margin-bottom: 8px;\"><strong>\u770b\u7b2c 2 \u540d\uff08\u5c9b A\uff09\uff1a<\/strong>\u5b83\u7684\u7ebf\u6bb5\u662f <strong>[1, 1]<\/strong>\uff0c\u5de6\u7aef\u70b9\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">1<\/span>\u3002\u56e0\u4e3a <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">1 &gt; -1.268<\/span>\uff0c\u8bf4\u660e\u5c9b A \u7684\u8303\u56f4\u5b8c\u5168\u5728\u7b2c\u4e00\u5ea7\u96f7\u8fbe\u7684\u53f3\u8fb9\uff0c\u8e6d\u4e0d\u5230\uff01\u6ca1\u529e\u6cd5\uff0c\u5fc5\u987b\u4fee\u7b2c 2 \u5ea7\u96f7\u8fbe\uff0c\u653e\u5728\u5c9b A \u7ebf\u6bb5\u7684\u6700\u53f3\u7aef <strong>1<\/strong> \u5904\u3002\uff08\u5f53\u524d\u96f7\u8fbe\u6570 = 2\uff0c\u5f53\u524d\u96f7\u8fbe\u4f4d\u7f6e\u66f4\u65b0\u4e3a = 1\uff09\u3002<\/li>\n                <li style=\"margin-bottom: 8px;\"><strong>\u770b\u7b2c 3 \u540d\uff08\u5c9b C\uff09\uff1a<\/strong>\u5b83\u7684\u7ebf\u6bb5\u662f <strong>[0.268, 3.732]<\/strong>\uff0c\u5de6\u7aef\u70b9\u662f <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">0.268<\/span>\u3002\u4e00\u770b\uff0c<span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">0.268 &le; 1<\/span>\uff01\u8fd9\u8bf4\u660e\u4f4d\u7f6e\u5728 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">1<\/span> \u7684\u8fd9\u5ea7\u96f7\u8fbe\uff0c\u6b63\u597d\u843d\u5728\u4e86 <span style=\"font-family: 'Times New Roman', serif; font-style: italic;\">[0.268, 3.732]<\/span> \u809a\u5b50\u91cc\u9762\uff01\u5c9b C \u6210\u529f\u767d\u5ad6\u7b2c 2 \u5ea7\u96f7\u8fbe\uff0c\u4e0d\u7528\u52a0\u65b0\u96f7\u8fbe\u3002<\/li>\n            <\/ul>\n        <\/div>\n\n        <p style=\"margin-top: 16px; font-weight: bold; color: #1a7f37;\">4. \u7ed3\u675f\uff1a\u6240\u6709\u7ebf\u6bb5\u68c0\u67e5\u5b8c\u6bd5\uff0c\u603b\u5171\u7528\u4e86 2 \u5ea7\u96f7\u8fbe\uff0c\u5b8c\u7f8e\u5bf9\u5e94 Sample Output \u7684 Case 1: 2\u3002<\/p>\n    <\/div>\n\n    <!-- \u7ed3\u5c3e -->\n    <div style=\"margin-top: 32px; padding-top: 20px; border-top: 1px dashed #e1e4e8; color: #57606a; font-size: 15.5px; font-style: italic;\">\n        \u6574\u4e2a\u601d\u8def\u91cc\u6709\u54ea\u4e00\u6b65\u7684\u8f6c\u6362\uff08\u6bd4\u5982\u52fe\u80a1\u5b9a\u7406\u7b97\u533a\u95f4\uff0c\u6216\u8005\u6309\u53f3\u7aef\u70b9\u6392\u5e8f\u7684\u539f\u56e0\uff09\u89c9\u5f97\u8fd8\u4e0d\u591f\u76f4\u89c2\u5417\uff1f\u6211\u4eec\u53ef\u4ee5\u9488\u5bf9\u90a3\u4e00\u6b65\u518d\u5355\u72ec\u5c55\u5f00\u804a\u804a\u3002\n    <\/div>\n\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">\u5f53\u7136\u4e5f\u662f\u6709\u4f18\u5316\u70b9\u7684<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u53bb\u6389\u591a\u4f59\u7684\u7b2c\u4e00\u6b21\u6392\u5e8f\uff08\u7701\u53bb\u4e00\u534a\u6392\u5e8f\u65f6\u95f4\uff09<\/strong>\uff1a\u4f60\u5728 <code>handle_input()<\/code> \u4e2d\u6309\u5c9b\u5c7f\u7684 $x$ \u5750\u6807\u6392\u4e86\u4e00\u6b21\u5e8f<sup><\/sup>\uff0c\u56de\u5230 <code>main<\/code> \u51fd\u6570\u7b97\u51fa\u7ebf\u6bb5\u540e\u53c8\u6309\u53f3\u7aef\u70b9\u6392\u4e86\u4e00\u6b21\u5e8f<sup><\/sup>\u3002\u5b9e\u9645\u4e0a\u7b2c\u4e00\u6b21\u6392\u5e8f\u4f1a\u88ab\u7b2c\u4e8c\u6b21\u5b8c\u5168\u8986\u76d6\uff0c\u76f4\u63a5\u5220\u6389 <code>handle_input<\/code> \u91cc\u7684 <code>sort<\/code> \u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u8fb9\u8bfb\u5165\u8fb9\u8f6c\u5316\uff08\u6d88\u9664\u4e2d\u95f4\u6570\u7ec4\uff09<\/strong>\uff1a\u4e0d\u9700\u8981\u5148\u628a\u6240\u6709 $(x, y)$ \u5b58\u8fdb <code>poss<\/code> \u6570\u7ec4\u518d\u904d\u5386\u8f6c\u5316<sup><\/sup>\u3002\u53ef\u4ee5\u5728\u8bfb\u53d6\u6bcf\u4e2a\u5c9b\u5c7f $(x, y)$ \u7684\u540c\u65f6\uff0c\u76f4\u63a5\u7b97\u51fa\u7ebf\u6bb5\u7684\u5de6\u53f3\u7aef\u70b9\u5b58\u5165 <code>lines<\/code>\uff08\u6ce8\u610f\uff1a\u5982\u679c\u53d1\u73b0\u65e0\u89e3\uff0c\u4ecd\u9700\u628a\u5f53\u524d\u7528\u4f8b\u5269\u4f59\u7684\u8f93\u5165\u884c\u8bfb\u5b8c\uff0c\u4ee5\u514d\u6c61\u67d3\u4e0b\u4e00\u4e2a\u7528\u4f8b\u7684\u8bfb\u53d6\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6280\u5de7\u6027\u7701\u7565\u81ea\u5b9a\u4e49\u6bd4\u8f83\u51fd\u6570<\/strong>\uff1aC++ \u7684 <code>pair&lt;double, double&gt;<\/code> \u9ed8\u8ba4\u5148\u6309 <code>first<\/code> \u4ece\u5c0f\u5230\u5927\u6392\u5e8f\u3002\u5982\u679c\u6211\u4eec\u5b58\u7ebf\u6bb5\u65f6\u628a<strong>\u53f3\u7aef\u70b9\u5b58\u5728 <code>first<\/code>\uff0c\u5de6\u7aef\u70b9\u5b58\u5728 <code>second<\/code><\/strong>\uff0c\u76f4\u63a5\u5199 <code>sort(lines.begin(), lines.end())<\/code> \u5c31\u80fd\u5929\u7136\u5b9e\u73b0\u6309\u53f3\u7aef\u70b9\u6392\u5e8f\uff0c\u8fde <code>compare<\/code> \u51fd\u6570\u90fd\u4e0d\u7528\u5199\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u7528\u5355\u4e2a\u53d8\u91cf\u4ee3\u66ff <code>poss_x<\/code> \u6570\u7ec4\uff08\u7a7a\u95f4\u590d\u6742\u5ea6\u4ece O(N)$\u964d\u4e3a O(1)\uff09<\/strong>\uff1a\u5224\u65ad\u540e\u7eed\u7ebf\u6bb5\u662f\u5426\u88ab\u8986\u76d6\u65f6\uff0c\u6bcf\u6b21\u53ea\u7528\u5230\u4e86 <code>poss_x.back()<\/code>\uff08\u5373\u6700\u540e\u4e00\u5ea7\u96f7\u8fbe\u7684\u4f4d\u7f6e\uff09\u3002\u56e0\u6b64\u6839\u672c\u4e0d\u9700\u8981\u7528 <code>vector<\/code> \u628a\u6bcf\u5ea7\u96f7\u8fbe\u7684\u5750\u6807\u90fd\u5b58\u4e0b\u6765\uff0c\u53ea\u9700\u7ef4\u62a4\u4e00\u4e2a <code>double last_radar<\/code> \u53d8\u91cf\u548c\u4e00\u4e2a <code>int count<\/code> \u8ba1\u6570\u5668\u5373\u53ef\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u6d41\u5f0f\u8f93\u51fa\u4e0e I\/O \u52a0\u901f<\/strong>\uff1a\u5904\u7406\u5b8c\u4e00\u4e2a\u6d4b\u8bd5\u7528\u4f8b\u76f4\u63a5\u8f93\u51fa\u4e00\u884c <code>Case X: Y<\/code><sup><\/sup>\uff0c\u65e0\u9700\u7528 <code>ans<\/code> \u6570\u7ec4\u6512\u5230\u6700\u540e\u518d\u8f93\u51fa<sup><\/sup>\uff1b\u52a0\u4e0a <code>ios::sync_with_stdio(false)<\/code> \u53ef\u4ee5\u5927\u5e45\u63d0\u5347 <code>cin\/cout<\/code> \u7684\u8bfb\u5199\u901f\u5ea6\u3002<\/p>\n\n\n\n<pre><code class=\"language-cpp\">#include &lt;iostream&gt;\n#include &lt;vector&gt;\n#include &lt;cmath&gt;\n#include &lt;algorithm&gt;\n\nusing namespace std;\n\nint main() {\n    \/\/ \u52a0\u901f C++ \u7684 cin \u548c cout \u8bfb\u5199\u6548\u7387\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n\n    int n, d, case_num = 1;\n    \/\/ \u53ea\u8981\u6210\u529f\u8bfb\u5165 n \u548c d\uff0c\u4e14\u4e0d\u90fd\u662f 0\uff0c\u5c31\u7ee7\u7eed\u5904\u7406\n    while (cin &gt;&gt; n &gt;&gt; d &amp;&amp; (n != 0 || d != 0)) {\n        \/\/ first \u5b58\u53f3\u7aef\u70b9 (end)\uff0csecond \u5b58\u5de6\u7aef\u70b9 (start)\uff0c\u5229\u7528 pair \u9ed8\u8ba4\u89c4\u5219\u76f4\u63a5\u6309\u53f3\u7aef\u70b9\u6392\u5e8f\n        vector&lt;pair&lt;double, double&gt;&gt; lines(n);\n        bool possible = (d &gt;= 0);\n\n        for (int i = 0; i &lt; n; i++) {\n            double x, y;\n            cin &gt;&gt; x &gt;&gt; y; \/\/ \u5fc5\u987b\u628a n \u884c\u5168\u90e8\u8bfb\u5b8c\uff0c\u4e0d\u80fd\u4e2d\u9014 break \u8df3\u8fc7 cin\n            if (y &gt; d || y &lt; 0) {\n                possible = false;\n            }\n            if (possible) {\n                double offset = sqrt((double)d * d - y * y);\n                lines[i].first = x + offset;  \/\/ \u53f3\u7aef\u70b9\u653e first\n                lines[i].second = x - offset; \/\/ \u5de6\u7aef\u70b9\u653e second\n            }\n        }\n\n        \/\/ \u5982\u679c\u65e0\u89e3\uff0c\u76f4\u63a5\u8f93\u51fa -1 \u5e76\u8fdb\u5165\u4e0b\u4e00\u8f6e\n        if (!possible) {\n            cout &lt;&lt; \"Case \" &lt;&lt; case_num++ &lt;&lt; \": -1\\n\";\n            continue;\n        }\n\n        \/\/ \u9ed8\u8ba4\u6309 first\uff08\u5373\u53f3\u7aef\u70b9\uff09\u4ece\u5c0f\u5230\u5927\u6392\u5e8f\n        sort(lines.begin(), lines.end());\n\n        \/\/ \u8d2a\u5fc3\u7edf\u8ba1\u96f7\u8fbe\u6570\u91cf\uff0c\u53ea\u8bb0\u5f55\u6700\u540e\u4e00\u5ea7\u96f7\u8fbe\u7684\u4f4d\u7f6e\n        int radar_count = 1;\n        double last_radar = lines[0].first; \/\/ \u7b2c\u4e00\u5ea7\u96f7\u8fbe\u653e\u5728\u7b2c\u4e00\u4e2a\u533a\u95f4\u7684\u53f3\u7aef\u70b9\n\n        for (int i = 1; i &lt; n; i++) {\n            \/\/ lines[i].second \u662f\u5f53\u524d\u533a\u95f4\u7684\u5de6\u7aef\u70b9\n            if (lines[i].second &gt; last_radar) {\n                radar_count++;\n                last_radar = lines[i].first; \/\/ \u66f4\u65b0\u96f7\u8fbe\u4f4d\u7f6e\u4e3a\u5f53\u524d\u533a\u95f4\u7684\u53f3\u7aef\u70b9\n            }\n        }\n\n        cout &lt;&lt; \"Case \" &lt;&lt; case_num++ &lt;&lt; \": \" &lt;&lt; radar_count &lt;&lt; \"\\n\";\n    }\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Radar\u00a0Installation\uff0810023\uff09 \u5b8c\u5168\u6ca1\u601d\u8def\uff0c\u5bf9\u5427\uff1f #include&lt;iostream&gt; #inc ...<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":""},"categories":[1],"tags":[],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":0,"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sirin.fun\/index.php\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}