{"id":49275,"date":"2024-12-02T15:01:31","date_gmt":"2024-12-02T07:01:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49275\/"},"modified":"2024-12-02T15:01:31","modified_gmt":"2024-12-02T07:01:31","slug":"%e5%85%ac%e4%ba%a4%e5%8d%a1%e5%85%85%e5%80%bc%ef%bc%9a%e5%a6%82%e4%bd%95%e8%ae%a1%e7%ae%97%e5%ae%9e%e9%99%85%e5%88%b0%e8%b4%a6%e9%87%91%e9%a2%9d%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49275\/","title":{"rendered":"\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f<\/h1>\n<p>\u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300a\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241130\/1732945373674aa5dd70a1e.jpg\" class=\"aligncenter\" title=\"\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f\u63d2\u56fe\" alt=\"\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u516c\u4ea4\u5361\u5145\u503c\u4f18\u60e0<\/strong><\/p>\n<p>\u5bf9\u4e8e\u516c\u4ea4\u5361\u5145\u503c\u6d3b\u52a8\uff0c\u6211\u4eec\u63d0\u4f9b\u4ee5\u4e0b\u95ee\u9898\u89e3\u7b54\uff1a<\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong>\u6839\u636e\u5145\u503c\u91d1\u989d\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\u3002<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<pre>import java.util.Scanner;\n\npublic class Main {\n\n    public static void main(String[] args) {\n        Scanner sc = new Scanner(System.in);\n        int n = sc.nextInt();\n\n        \/\/ \u8bbe\u7f6e\u5145\u503c\u91d1\u989d\u533a\u95f4\u548c\u5bf9\u5e94\u8d60\u9001\u91d1\u989d\n        int[][] intervals = {\n            \/\/ \u5145\u503c\u91d1\u989d\u533a\u95f4       \u8d60\u9001\u91d1\u989d\n            {200, 299, 50},\n            {300, 499, 100},\n            {500, Integer.MAX_VALUE, 200}\n        };\n\n        \/\/ \u6839\u636e\u5145\u503c\u91d1\u989d\u67e5\u627e\u5bf9\u5e94\u533a\u95f4\n        for (int[] interval : intervals) {\n            if (n &gt;= interval[0] &amp;&amp; n &lt;= interval[1]) {\n                System.out.println(n + interval[2]);\n                return;\n            }\n        }\n\n        \/\/ \u4f4e\u4e8e\u6700\u4f4e\u5145\u503c\u91d1\u989d\n        if (n &lt; intervals[0][0]) {\n            System.out.println(n);\n        }\n    }\n}<\/pre>\n<p>\u8be5\u4ee3\u7801\u6839\u636e\u5145\u503c\u91d1\u989d\u8303\u56f4\u5224\u65ad\u8d60\u9001\u91d1\u989d\uff0c\u5e76\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff0c\u8003\u8651\u4e86\u5145\u503c\u91d1\u989d\u4e3a0\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f \u77e5\u8bc6\u70b9\u638c\u63e1\u4e86\uff0c\u8fd8\u9700\u8981\u4e0d\u65ad\u7ec3\u4e60\u624d\u80fd\u719f\u7ec3\u8fd0\u7528\u3002\u4e0b\u9762\u7c73\u4e91\u7ed9\u5927\u5bb6\u5e26\u6765\u4e00\u4e2a\u6587\u7ae0\u5f00\u53d1\u5b9e\u6218\uff0c\u624b\u628a\u624b\u6559\u5927\u5bb6\u5b66\u4e60\u300a\u516c\u4ea4\u5361\u5145\u503c\uff1a\u5982\u4f55\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\uff1f\u300b\uff0c\u5728\u5b9e\u73b0\u529f\u80fd\u7684\u8fc7\u7a0b\u4e2d\u4e5f\u5e26\u5927\u5bb6\u91cd\u65b0\u6e29\u4e60\u76f8\u5173\u77e5\u8bc6\u70b9\uff0c\u6e29\u6545\u800c\u77e5\u65b0\uff0c\u56de\u5934\u770b\u770b\u8bf4\u4e0d\u5b9a\u53c8\u6709\u4e0d\u4e00\u6837\u7684\u611f\u609f\uff01 \u516c\u4ea4\u5361\u5145\u503c\u4f18\u60e0 \u5bf9\u4e8e\u516c\u4ea4\u5361\u5145\u503c\u6d3b\u52a8\uff0c\u6211\u4eec\u63d0\u4f9b\u4ee5\u4e0b\u95ee\u9898\u89e3\u7b54\uff1a \u95ee\u9898\uff1a\u6839\u636e\u5145\u503c\u91d1\u989d\u8ba1\u7b97\u5b9e\u9645\u5230\u8d26\u91d1\u989d\u3002 \u89e3\u7b54\uff1a import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); \/\/ \u8bbe\u7f6e\u5145\u503c\u91d1\u989d\u533a\u95f4\u548c\u5bf9\u5e94\u8d60\u9001\u91d1\u989d int[][] intervals = { \/\/ \u5145\u503c\u91d1\u989d\u533a\u95f4 \u8d60\u9001\u91d1\u989d {200, 299, 50}, {300, 499, 100}, {500, Integer.MAX_VALUE, 200} }; \/\/ \u6839\u636e\u5145\u503c\u91d1\u989d\u67e5\u627e\u5bf9\u5e94\u533a\u95f4 for (int[] interval : intervals) { if [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49275","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49275"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49275\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}