{"id":12779,"date":"2025-04-18T19:54:53","date_gmt":"2025-04-18T11:54:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/12779.html"},"modified":"2025-04-18T19:54:53","modified_gmt":"2025-04-18T11:54:53","slug":"2023%e7%ac%ac%e5%8d%81%e5%9b%9b%e5%b1%8a%e8%93%9d%e6%a1%a5%e6%9d%af%e5%a4%a7%e8%b5%9b%e8%bd%af%e4%bb%b6%e8%b5%9b%e5%9b%bd%e8%b5%9bc-c-%e5%a4%a7%e5%ad%a6-b-%e7%bb%84%e7%9c%9f%e9%a2%98%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/12779.html","title":{"rendered":"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09"},"content":{"rendered":"<p>\u672c\u6765\u60f3\u5237\u7701\u8d5b\u9898\u5462&#xff0c;\u7ed3\u679c\u4e00\u4e0d\u5c0f\u5fc3\u5237\u6210\u56fd\u8d5b\u4e86 \u771f\u662f\u4e2a\u5c0f\u8ff7\u7cca\u3012\u25bd\u3012 \u4f46&#xff0c;\u53c8\u5982\u4f55( \u2022\u0300 \u03c9 \u2022\u0301 )\u2727 \u8bb0\u5f55\u5237\u9898\u7684\u8fc7\u7a0b\u3001\u611f\u609f\u3001\u9898\u89e3\u3002 \u5e0c\u671b\u80fd\u5e2e\u5230&#xff0c;\u90a3\u4e9b\u4e0e\u6211\u4e00\u540c\u524d\u884c\u7684&#xff0c;\u6765\u81ea\u8fdc\u65b9\u7684\u670b\u53cb&#x1f609;<\/p>\n<hr \/>\n<p>\u6ce8&#xff1a;\u611f\u8c22&#064;Witton\u7684\u63d0\u793a&#xff0c;\u9898\u76ee\u90e8\u5206\u5df2\u5b8c\u6210\u4fee\u6539( \u2022\u0300 \u03c9 \u2022\u0301 )y<\/p>\n<hr \/>\n<h4>\u5927\u7eb2&#xff1a;<\/h4>\n<p>\u4e00\u3001\u5b502023-&#xff08;\u9898\u89e3&#xff09;-\u9012\u63a8or\u52a8\u6001\u89c4\u5212<\/p>\n<p>\u4e8c\u3001\u53cc\u5b50\u6570-&#xff08;\u9898\u89e3&#xff09;-\u7b5b\u6cd5\u3001\u7c7b\u578b(unsigned long long)&#x1f625;<\/p>\n<p>\u4e09\u3001\u73ed\u7ea7\u6d3b\u52a8-&#xff08;\u9898\u89e3&#xff09;-\u4e0d\u51fa\u6240\u6599\u3001\u8d2a\u5fc3&#043;\u8ba1\u6570<\/p>\n<p>\u56db\u3001\u5408\u5e76\u6570\u5217-&#xff08;\u9898\u89e3&#xff09;-\u59a5\u59a5\u7684\u524d\u7f00\u548c&#x1f625;&#xff0c;\u5f53\u7136\u53cc\u6307\u9488\u4e5f\u80fd\u505a<\/p>\n<p>\u4e94\u3001\u6570\u4e09\u89d2-&#xff08;\u9898\u89e3&#xff09;-\u8fd9\u4e2a\u771f\u7684\u5c31\u662f\u7b97\u672f\u9898\u4e86&#xff0c;\u8fd8\u8981\u7528\u5230\u5404\u79cd\u4f18\u5316&#xff08;\u53c9\u4e58\u3001\u7528\u534a\u5f84\u5206\u7ec4&#xff09;<\/p>\n<p>\u516d\u3001\u5220\u8fb9\u95ee\u9898-&#xff08;\u9898\u89e3&#xff09;-\u56fe(tarjan\u7b97\u6cd5)\u5272\u8fb9\u3001\u5272\u70b9&#xff0c;\u7ecf\u5178\u677f\u5b50\u9898<\/p>\n<p>\u4e03\u3001AB\u8def\u7ebf-&#xff08;\u9898\u89e3&#xff09;-BFS\u5e7f\u641c&#xff0c;\u6700\u77ed\u8def\u5f84\u3001\u8bb0\u5fc6\u8bdd\u641c\u7d22&#x1f609;<\/p>\n<p>\u516b\u3001\u6293\u5a03\u5a03-&#xff08;\u9898\u89e3&#xff09;-\u7b80\u5355\u70b9\u7684\u5dee\u5206&#043;\u524d\u7f00\u548c&#x1f60a;<\/p>\n<p>\u4e5d\u3001\u5341&#xff0c;\u7b49\u540e\u7eed\u51b2\u51fb\u56fd\u8d5b\u65f6&#xff0c;\u518d\u89e3\u51b3\u3002<\/p>\n<hr \/>\n<h4>\u4e00\u3001\u5b502023<\/h4>\n<h5 id=\"\u95ee\u9898\u63cf\u8ff0\"><span style=\"color:#1c7892\">\u95ee\u9898\u63cf\u8ff0<\/span><\/h5>\n<p>\u5c0f\u84dd\u5728\u9ed1\u677f\u4e0a\u8fde\u7eed\u5199\u4e0b\u4ece\u00a01\u00a0\u5230\u00a02023\u4e4b\u95f4\u6240\u6709\u7684\u6574\u6570&#xff0c;\u5f97\u5230\u4e86\u4e00\u4e2a\u6570\u5b57\u5e8f\u5217&#xff1a;\u00a0S&#061;12345678910111213&#8230;20222023\u3002 \u5c0f\u84dd\u60f3\u77e5\u9053\u00a0S\u00a0\u4e2d\u6709\u591a\u5c11\u79cd\u5b50\u5e8f\u5217\u6070\u597d\u7b49\u4e8e 2023&#xff1f;<\/p>\n<p>\u4ee5\u4e0b\u662f\u00a03 \u79cd\u6ee1\u8db3\u6761\u4ef6\u7684\u5b50\u5e8f\u5217&#xff08;\u7528\u4e2d\u62ec\u53f7\u6807\u8bc6\u51fa\u7684\u6570\u5b57\u662f\u5b50\u5e8f\u5217\u5305\u542b\u7684\u6570\u5b57&#xff09;&#xff1a;<\/p>\n<p>1[2]34567891[0]111[2]1[3]14151617181920212223&#8230; 1[2]34567891[0]111[2]131415161718192021222[3]&#8230; 1[2]34567891[0]111213141516171819[2]021222[3]&#8230;<\/p>\n<p>\u6ce8\u610f\u4ee5\u4e0b\u662f\u4e0d\u6ee1\u8db3\u6761\u4ef6\u7684\u5b50\u5e8f\u5217&#xff0c;\u867d\u7136\u5305\u542b\u4e86\u00a02\u30010\u30012\u30013\u00a0\u56db\u4e2a\u6570\u5b57&#xff0c;\u4f46\u662f\u987a\u5e8f\u4e0d\u5bf9&#xff1a;<\/p>\n<p>1[2]345678910111[2]131415161718192[0]21222[3]&#8230;<\/p>\n<p id=\"\u7b54\u6848\u63d0\u4ea4\">\u7b54\u6848\u63d0\u4ea4<\/p>\n<p>\u8fd9\u662f\u4e00\u9053\u7ed3\u679c\u586b\u7a7a\u7684\u9898&#xff0c;\u4f60\u53ea\u9700\u8981\u7b97\u51fa\u7ed3\u679c\u540e\u63d0\u4ea4\u5373\u53ef\u3002\u672c\u9898\u7684\u7ed3\u679c\u4e3a\u4e00\u4e2a\u6574\u6570&#xff0c;\u5728\u63d0\u4ea4\u7b54\u6848\u65f6\u53ea\u586b\u5199\u8fd9\u4e2a\u6574\u6570&#xff0c;\u586b\u5199\u591a\u4f59\u7684\u5185\u5bb9\u5c06\u65e0\u6cd5\u5f97\u5206\u3002<\/p>\n<h5><span style=\"color:#1c7892\">\u52a8\u6001\u89c4\u5212\u89e3\u6cd5&#xff1a;<\/span><\/h5>\n<p>\u672c\u9898\u89e3\u6cd5&#xff0c;\u8bf4\u6210\u662f\u72b6\u6001\u89c4\u5212&#xff0c;\u53ef\u80fd\u4f1a\u5f15\u8d77\u6050\u60e7&#xff0c;\u5176\u5b9e\u5b83\u5c31\u662f\u4e00\u9053\u7b80\u5355\u7684\u72b6\u6001\u63a8\u5bfc\u9898( \u2022\u0300 \u03c9 \u2022\u0301 )\u2727<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\nusing namespace std;<br \/>\n\/\/ \u662f\u4e2a\u7b80\u5355\u7684\u52a8\u6001\u89c4\u5212\u5c31\u7b97\u4e86<br \/>\n\/\/ \u600e\u4e48\u53c8\u662f\u4e00\u9053\u8d8a\u754c\u9898\u76ee<br \/>\n\/\/ \u4ee5\u540e\u7edf\u4e00\u4e0d\u7528long long\u6539\u7528 unsigned long long\u3002\u66f4\u5927\u3002<br \/>\nint main(){<br \/>\n    vector&lt;unsigned long long&gt; dp(4,0);<br \/>\n    string str&#061;&#034;&#034;;<br \/>\n    for(int i&#061;1; i&lt;&#061;2023; &#043;&#043;i) str&#043;&#061;to_string(i);<br \/>\n    \/\/ \u672c\u9898\u7684\u89e3\u6cd5\u662f\u52a8\u6001\u89c4\u5212<br \/>\n    for(char c : str){<br \/>\n        if(c&#061;&#061;&#039;2&#039;){<br \/>\n            dp[0]&#043;&#043;;<br \/>\n            dp[2]&#043;&#061;dp[1];<br \/>\n        }<br \/>\n        if(c&#061;&#061;&#039;0&#039;) dp[1]&#043;&#061;dp[0];<br \/>\n        if(c&#061;&#061;&#039;3&#039;) dp[3]&#043;&#061;dp[2];<br \/>\n    }<br \/>\n    cout&lt;&lt;dp[3]&lt;&lt;endl;<br \/>\n    return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> public class DpProblem {<br \/>\n    public static void main(String[] args) {<br \/>\n        \/\/ \u521b\u5efa\u4e00\u4e2a\u957f\u5ea6\u4e3a 4 \u7684 long \u7c7b\u578b\u6570\u7ec4 dp \u5e76\u521d\u59cb\u5316\u4e3a 0<br \/>\n        long[] dp &#061; new long[4];<\/p>\n<p>        \/\/ \u62fc\u63a5\u5b57\u7b26\u4e32<br \/>\n        StringBuilder str &#061; new StringBuilder();<br \/>\n        for (int i &#061; 1; i &lt;&#061; 2023; i&#043;&#043;) {<br \/>\n            str.append(i);<br \/>\n        }<\/p>\n<p>        \/\/ \u52a8\u6001\u89c4\u5212\u8fc7\u7a0b<br \/>\n        for (int i &#061; 0; i &lt; str.length(); i&#043;&#043;) {<br \/>\n            char c &#061; str.charAt(i);<br \/>\n            if (c &#061;&#061; &#039;2&#039;) {<br \/>\n                dp[0]&#043;&#043;;<br \/>\n                dp[2] &#043;&#061; dp[1];<br \/>\n            }<br \/>\n            if (c &#061;&#061; &#039;0&#039;) {<br \/>\n                dp[1] &#043;&#061; dp[0];<br \/>\n            }<br \/>\n            if (c &#061;&#061; &#039;3&#039;) {<br \/>\n                dp[3] &#043;&#061; dp[2];<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ \u8f93\u51fa\u7ed3\u679c<br \/>\n        System.out.println(dp[3]);<br \/>\n    }<br \/>\n}     <\/p>\n<h4>\u4e8c\u3001\u53cc\u5b50\u6570<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u82e5\u4e00\u4e2a\u6b63\u6574\u6570\u00a0x\u00a0\u53ef\u4ee5\u88ab\u8868\u793a\u4e3a\u00a0p2\u00d7q2&#xff0c;\u5176\u4e2d\u00a0p\u3001q\u00a0\u4e3a\u8d28\u6570\u4e14\u00a0p\u2260q&#xff0c;\u5219\u00a0x\u00a0\u662f\u4e00\u4e2a\u53cc\u5b50\u6570\u3002\u8bf7\u8ba1\u7b97\u533a\u95f4\u00a0[2333,\u202d23333333333333\u202c] \u5185\u6709\u591a\u5c11\u4e2a\u53cc\u5b50\u6570&#xff1f;<\/p>\n<p id=\"\u7b54\u6848\u63d0\u4ea4\">\u7b54\u6848\u63d0\u4ea4<\/p>\n<p>\u8fd9\u662f\u4e00\u9053\u7ed3\u679c\u586b\u7a7a\u7684\u9898&#xff0c;\u4f60\u53ea\u9700\u8981\u7b97\u51fa\u7ed3\u679c\u540e\u63d0\u4ea4\u5373\u53ef\u3002\u672c\u9898\u7684\u7ed3\u679c\u4e3a\u4e00\u4e2a\u6574\u6570&#xff0c;\u5728\u63d0\u4ea4\u7b54\u6848\u65f6\u53ea\u586b\u5199\u8fd9\u4e2a\u6574\u6570&#xff0c;\u586b\u5199\u591a\u4f59\u7684\u5185\u5bb9\u5c06\u65e0\u6cd5\u5f97\u5206\u3002<\/p>\n<p>\/\/ \u6211\u672c\u4ee5\u4e3a&#xff0c;\u672c\u9898\u6700\u96be\u7684\u662f\u6b27\u62c9\u7b5b&#xff0c;\u4e5f\u5c31\u662f\u7ebf\u6027\u7b5b \/\/ \u540e\u6765\u6211\u53d1\u73b0&#xff0c;\u6211\u9519\u4e86&#xff0c;\u800c\u4e14\u9519\u7684\u79bb\u8c31 \/\/ \u6b27\u62c9\u7b5b&#xff0c;\u80fd\u7528\u57c3\u6c0f\u7b5b\u4ee3\u66ff&#xff0c;\u80fd\u7528\u6734\u7d20\u4e5f\u5c31\u662f\u66b4\u529b\u6cd5\u4ee3\u66ff\u3002 \/\/ \u800c\u672c\u9898\u6700\u5927\u7684\u96be\u70b9\u662f\u7b26\u53f7\u4f4d&#xff0c;\u5982\u679c\u4f60\u5f00\u5230(long long)&#xff0c;\u7b54\u6848\u4f1a\u59cb\u7ec8\u591a10&#xff0c;\u8ba9\u4f60\u75db\u4e0d\u6b32\u751f\u3002 \/\/ \u672c\u9898\u8981\u5f00\u5230&#xff0c;unsigned long long \/\/ int-&gt;1e9 , long long-&gt;1e18, unsigned long long\u662flonglong\u7684\u4e24\u500d<\/p>\n<p>\/\/ \u5207\u8bb0&#xff0c;\u4e0d\u4f1a\u6b27\u62c9\u7b5b\u7684&#xff0c;\u53ef\u4ee5\u7528\u7ebf\u6027\u7b5b\u4ee3\u66ff&#xff0c;\u6216\u8005\u76f4\u63a5\u66b4\u529b&#xff08;\u4f1a\u6162\u4e00\u4e9b&#xff09;:: \u56db\u79cd\u7b5b\u6cd5 ::<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#define ll long long<br \/>\nusing namespace std;<\/p>\n<p>const int N &#061;  1e7 &#043; 10;<br \/>\nvector&lt;bool&gt; vec(N, true); \/\/ \u5047\u8bbe\u90fd\u662f\u8d28\u6570<br \/>\nvector&lt;ll&gt; res;<br \/>\nvoid sieve(){ \/\/ \u6b27\u62c9\u7b5b<br \/>\n    vec[0]&#061;vec[1]&#061; false;<br \/>\n    for(int i&#061;2; i&lt;vec.size(); &#043;&#043;i){<br \/>\n        if(vec[i]) res.push_back((ll)i);<br \/>\n        for(ll num:res){<br \/>\n            if(num*i&gt;vec.size()) break; \/\/ \u8d85\u51fa\u6700\u5927\u8303\u56f4<br \/>\n            vec[i*num] &#061; false;<br \/>\n            if(i%num&#061;&#061;0) break; \/\/ \u786e\u4fdd\u6bcf\u4e2a\u5408\u6570&#xff0c;\u53ea\u88ab\u6700\u5c0f\u56e0\u5b50\u9664\u53bb\u3002<br \/>\n        }<br \/>\n    }<br \/>\n}<br \/>\n\/\/\u5929\u5450&#xff0c;\u4f60\u8981\u8fd9\u6837\u73a9&#xff1f;\u8fd8\u548b\u73a9&#xff1f;&#xff1f;<br \/>\nint main(){<br \/>\n    sieve();<br \/>\n    ll num &#061; 0;<br \/>\n    for(ll i&#061;0;i&lt;res.size();i&#043;&#043;){<br \/>\n        unsigned ll pp &#061; res[i]*res[i];<br \/>\n        if(pp * pp &gt;23333333333333) break;\/\/\u4e00\u70b9\u5c0f\u4f18\u5316<br \/>\n        for(ll j&#061;i&#043;1;j&lt;res.size();j&#043;&#043;){<br \/>\n            ll qq &#061; res[j]*res[j];<br \/>\n            if(pp*qq&gt;23333333333333) break;<br \/>\n            if(pp*qq&lt;2333) continue;<br \/>\n            num&#043;&#043;;<br \/>\n        }<br \/>\n    }<br \/>\n    cout&lt;&lt;num&lt;&lt;endl;<br \/>\n    return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> import java.math.BigInteger;<br \/>\nimport java.util.ArrayList;<br \/>\nimport java.util.List;<\/p>\n<p>public class PrimeNumberCombination {<br \/>\n    \/\/ \u5b9a\u4e49\u5e38\u91cf N&#xff0c;\u7528\u4e8e\u7b5b\u6cd5\u8303\u56f4<br \/>\n    static final int N &#061; 10000010;<br \/>\n    \/\/ \u6807\u8bb0\u6bcf\u4e2a\u6570\u662f\u5426\u4e3a\u8d28\u6570\u7684\u5e03\u5c14\u6570\u7ec4<br \/>\n    static boolean[] isPrime &#061; new boolean[N];<br \/>\n    \/\/ \u5b58\u50a8\u8d28\u6570\u7684\u5217\u8868<br \/>\n    static List&lt;Integer&gt; primes &#061; new ArrayList&lt;&gt;();<\/p>\n<p>    \/\/ \u6b27\u62c9\u7b5b\u51fd\u6570&#xff0c;\u7b5b\u9009\u51fa\u6240\u6709\u8d28\u6570<br \/>\n    public static void sieve() {<br \/>\n        \/\/ \u521d\u59cb\u5316\u6240\u6709\u6570\u4e3a\u8d28\u6570<br \/>\n        for (int i &#061; 0; i &lt; N; i&#043;&#043;) {<br \/>\n            isPrime[i] &#061; true;<br \/>\n        }<br \/>\n        \/\/ 0 \u548c 1 \u4e0d\u662f\u8d28\u6570<br \/>\n        isPrime[0] &#061; isPrime[1] &#061; false;<br \/>\n        for (int i &#061; 2; i &lt; N; i&#043;&#043;) {<br \/>\n            if (isPrime[i]) {<br \/>\n                primes.add(i);<br \/>\n            }<br \/>\n            for (int prime : primes) {<br \/>\n                if (prime * i &gt;&#061; N) {<br \/>\n                    break;<br \/>\n                }<br \/>\n                isPrime[prime * i] &#061; false;<br \/>\n                if (i % prime &#061;&#061; 0) {<br \/>\n                    break;<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        \/\/ \u8c03\u7528\u6b27\u62c9\u7b5b\u51fd\u6570<br \/>\n        sieve();<br \/>\n        BigInteger limit1 &#061; BigInteger.valueOf(23333333333333L);<br \/>\n        BigInteger limit2 &#061; BigInteger.valueOf(2333L);<br \/>\n        long num &#061; 0;<br \/>\n        for (int i &#061; 0; i &lt; primes.size(); i&#043;&#043;) {<br \/>\n            BigInteger pp &#061; BigInteger.valueOf(primes.get(i)).pow(2);<br \/>\n            if (pp.pow(2).compareTo(limit1) &gt; 0) {<br \/>\n                break;<br \/>\n            }<br \/>\n            for (int j &#061; i &#043; 1; j &lt; primes.size(); j&#043;&#043;) {<br \/>\n                BigInteger qq &#061; BigInteger.valueOf(primes.get(j)).pow(2);<br \/>\n                BigInteger product &#061; pp.multiply(qq);<br \/>\n                if (product.compareTo(limit1) &gt; 0) {<br \/>\n                    break;<br \/>\n                }<br \/>\n                if (product.compareTo(limit2) &lt; 0) {<br \/>\n                    continue;<br \/>\n                }<br \/>\n                num&#043;&#043;;<br \/>\n            }<br \/>\n        }<br \/>\n        \/\/ \u8f93\u51fa\u6ee1\u8db3\u6761\u4ef6\u7684\u7ec4\u5408\u6570\u91cf<br \/>\n        System.out.println(num);<br \/>\n    }<br \/>\n}     <\/p>\n<h4>\u4e09\u3001\u73ed\u7ea7\u6d3b\u52a8<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u5c0f\u660e\u7684\u8001\u5e08\u51c6\u5907\u7ec4\u7ec7\u4e00\u6b21\u73ed\u7ea7\u6d3b\u52a8\u3002\u73ed\u4e0a\u4e00\u5171\u6709\u00a0n\u00a0\u540d (n\u00a0\u4e3a\u5076\u6570) \u540c\u5b66&#xff0c;\u8001\u5e08\u60f3\u628a\u6240\u6709\u7684\u540c\u5b66\u8fdb\u884c\u5206\u7ec4&#xff0c;\u6bcf\u4e24\u540d\u540c\u5b66\u4e00\u7ec4\u3002\u4e3a\u4e86\u516c\u5e73&#xff0c;\u8001\u5e08\u7ed9\u6bcf\u540d\u540c\u5b66\u968f\u673a\u5206\u914d\u4e86\u4e00\u4e2a\u00a0n\u00a0\u4ee5\u5185\u7684\u6b63\u6574\u6570\u4f5c\u4e3a\u00a0id&#xff0c;\u7b2c\u00a0i\u00a0\u540d\u540c\u5b66\u7684\u00a0id\u00a0\u4e3a\u00a0ai\u200b\u3002<\/p>\n<p>\u8001\u5e08\u5e0c\u671b\u901a\u8fc7\u66f4\u6539\u82e5\u5e72\u540d\u540c\u5b66\u7684\u00a0id\u00a0\u4f7f\u5f97\u5bf9\u4e8e\u4efb\u610f\u4e00\u540d\u540c\u5b66\u00a0i&#xff0c;\u6709\u4e14\u4ec5\u6709\u53e6\u4e00\u540d\u540c\u5b66\u00a0jj\u00a0\u7684\u00a0idid\u00a0\u4e0e\u5176\u76f8\u540c (ai&#061;aj\u200b)\u3002\u8bf7\u95ee\u8001\u5e08\u6700\u5c11\u9700\u8981\u66f4\u6539\u591a\u5c11\u540d\u540c\u5b66\u7684\u00a0id&#xff1f;<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u8f93\u5165\u5171\u00a02\u00a0\u884c\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e3a\u4e00\u4e2a\u6b63\u6574\u6570\u00a0n\u3002<\/p>\n<p>\u7b2c\u4e8c\u884c\u4e3a\u00a0n\u00a0\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570\u00a0a1,a2,&#8230;,an\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u8f93\u51fa\u5171\u00a01\u00a0\u884c&#xff0c;\u4e00\u4e2a\u6574\u6570\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  4<br \/>\n1 2 2 3<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  1<\/p>\n<p id=\"\u6837\u4f8b\u8bf4\u660e\">\u6837\u4f8b\u8bf4\u660e<\/p>\n<p>\u4ec5\u9700\u8981\u628a\u00a0a1\u200b\u00a0\u6539\u4e3a\u00a03\u00a0\u6216\u8005\u628a\u00a0a3\u200b\u00a0\u6539\u4e3a\u00a01\u00a0\u5373\u53ef\u3002<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e 20%\u00a0\u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n\u226410^3\u3002<\/p>\n<p>\u5bf9\u4e8e\u00a0100% \u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n\u226410^5<\/p>\n<p>\/\/ \u2686_\u2686&#xff1f;\u5f53\u6211\u627e\u5230\u54ea\u91cc\u9519\u4e86\u4e4b\u540e&#xff0c;\u6cea\u6d41\u6ee1\u9762 \/\/ \u672c\u9898\u5176\u5b9e\u633a\u7b80\u5355 \/\/ \u8bfb\u9898&#xff1a;\u201c\u6bcf\u540d\u540c\u5b66&#xff0c;\u968f\u673a\u5206\u914dn\u4ee5\u5185\u7684\u6b63\u6574\u6570\u4f5c\u4e3aid\u201d\u00a0 \/\/ \u8fd9\u8bf4\u660e&#xff0c;\u6bcf\u4e2a\u540c\u5b66\u7684id\u6709\u4e24\u79cd\u60c5\u51b5\u3002 \/\/ \u6b64\u65f6\u4e3e\u4e00\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\u5c31OK\u4e86 \/\/ \u50cf\u9898\u76ee\u4e2d\u4e3e\u5f97\u4f8b\u5b50&#xff0c;1 2 2 3 \u4e00\u7ec4&#xff08;2,2&#xff09;\u5c31\u80fd\u914d\u5bf9&#xff0c;\u4ec5\u9700\u66f4\u65393\u53d8\u62101&#xff08;1-&gt;3\u4e5f\u884c&#xff09;\u5c31OK\u4e86&#xff0c;\u53ea\u9700\u4e00\u6b21\u3002 \/\/ \u63a8\u7b97\u6210\u516c\u5f0f&#xff0c;\u4e5f\u5c31\u662f 2\/1&#061;1 -&gt; \u6563\u5217\u7684\u603b\u6570\/2 \/\/ \u8fdb\u9636\u4e00\u70b9&#xff0c;\u5f53id\u4e3a 2 2 2 1\u65f6&#xff0c;\u6b64\u65f6\u4e00\u7ec4&#xff08;2,2&#xff09;\u5c31\u80fd\u914d\u5bf9&#xff0c;\u8fd9\u65f6\u4ec5\u9700\u66f4\u6539\u5269\u4e0b\u76842\u53d8\u62101\u5c31OK\u4e86&#xff0c;\u4e5f\u53ea\u9700\u8981\u66f4\u6539\u4e00\u6b21\u3002 \/\/ \u5982\u679c\u662f 2 2 2 2 2 1 \u5462&#xff0c;\u8981\u5148\u53bb\u6389\u4e00\u7ec4&#xff08;2,2&#xff09; \/\/ \u6b64\u65f6\u5269\u4e0b 2 2 2 1&#xff0c;\u56e0\u4e3a\u4e0d\u80fd\u4e0e\u5df2\u7ecf\u914d\u5bf9\u7684&#xff08;2,2&#xff09;\u91cd\u590d&#xff0c; \/\/ \u6240\u4ee5\u5148\u628a\u5176\u4e2d\u4e00\u4e2a2\u6539\u4e3a1&#xff0c;\u9700\u8981\u4e00\u6b21\u3002 \/\/ \u6b64\u65f6\u5269\u4e0b 2 2&#xff0c;\u53ea\u9700\u5c06\u5b83\u4eec\u6539\u6210\u5176\u4ed6\u6570\u5c31\u884c&#xff0c;\u5982\u6539\u6210&#xff08;3,3&#xff09;&#xff0c;\u9700\u8981\u4e24\u6b21\u3002 \/\/ \u4e00\u5171\u7528\u4e863\u6b21&#xff0c;\u4e5f\u5c31\u662f2\u7684\u603b\u6570 \u51cf\u53bb2 \u4e5f\u5c31\u662f\u51cf\u53bb&#xff08;2,2&#xff09;\u8fd9\u4e2a\u4e0d\u9700\u8981\u6539\u53d8\u7684\u7ec4\u5408\u3002 \/\/ \u4e5f\u5c31\u662f \u5f53\u5df2\u88ab\u5360\u7528\u7684id\u7684\u6570\u91cf&#xff0c;\u5927\u4e8e\u672a\u88ab\u5360\u7528id\u65f6&#xff0c;\u603b\u6570\u7b49\u4e8e \u91cd\u590d id\u7684\u6570\u91cf\u3002<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\nconst int N &#061; 1e5&#043;5;<br \/>\nusing namespace std;<br \/>\nint arr[N]; <\/p>\n<p>int main()<br \/>\n{<br \/>\n  int n;<br \/>\n  cin&gt;&gt;n;<br \/>\n  for(int i&#061;0; i&lt;n; &#043;&#043;i){<br \/>\n    int num;<br \/>\n    cin&gt;&gt;num;<br \/>\n    arr[num]&#043;&#043;;<br \/>\n  }<\/p>\n<p>  int num1&#061;0, num2&#061;0;<\/p>\n<p>  for(int i : arr){<br \/>\n    if(i&gt;2) num1 &#043;&#061; i-2; \/\/ \u6c42\u53d6\u6570\u91cf\u76f8\u540c\u7684\u6570\u5728\u51cf2&#xff1b;<br \/>\n    else if(i&#061;&#061;1) num2&#043;&#043;;<br \/>\n  }<\/p>\n<p>  int sum &#061; 0;<br \/>\n  \/\/ \u5f53\u5df2\u88ab\u5360\u7528\u7684id\u7684\u6570\u91cf&#xff0c;\u5927\u4e8e\u672a\u88ab\u5360\u7528id\u65f6&#xff0c;\u90a3\u4e48sum &#061; num1;<br \/>\n  if(num1&gt;num2){<br \/>\n    sum &#061; num1;<br \/>\n  }else{ \/\/ num2&lt;num1\u7684\u60c5\u51b5<br \/>\n    sum &#061; num2 &#043; (num1-num2)\/2;<br \/>\n  }<br \/>\n  cout&lt;&lt;sum&lt;&lt;endl;<br \/>\n  return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> import java.util.Scanner;<\/p>\n<p>public class StudentIdAdjustment {<br \/>\n    \/\/ \u5b9a\u4e49\u5e38\u91cf N&#xff0c;\u7528\u4e8e\u6570\u7ec4\u5927\u5c0f<br \/>\n    static final int N &#061; 100005;<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        \/\/ \u521b\u5efa Scanner \u5bf9\u8c61\u7528\u4e8e\u8bfb\u53d6\u8f93\u5165<br \/>\n        Scanner scanner &#061; new Scanner(System.in);<br \/>\n        \/\/ \u5b9a\u4e49\u4e00\u4e2a\u6570\u7ec4\u6765\u8bb0\u5f55\u6bcf\u4e2a ID \u51fa\u73b0\u7684\u6b21\u6570<br \/>\n        int[] arr &#061; new int[N];<br \/>\n        \/\/ \u8bfb\u53d6\u5b66\u751f\u7684\u6570\u91cf<br \/>\n        int n &#061; scanner.nextInt();<\/p>\n<p>        \/\/ \u5faa\u73af\u8bfb\u53d6\u6bcf\u4e2a\u5b66\u751f\u7684 ID&#xff0c;\u5e76\u7edf\u8ba1\u6bcf\u4e2a ID \u51fa\u73b0\u7684\u6b21\u6570<br \/>\n        for (int i &#061; 0; i &lt; n; i&#043;&#043;) {<br \/>\n            int num &#061; scanner.nextInt();<br \/>\n            arr[num]&#043;&#043;;<br \/>\n        }<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u4e24\u4e2a\u53d8\u91cf&#xff0c;\u7528\u4e8e\u7edf\u8ba1\u9700\u8981\u5904\u7406\u7684\u4e0d\u540c\u60c5\u51b5\u7684\u6570\u91cf<br \/>\n        int num1 &#061; 0;<br \/>\n        int num2 &#061; 0;<\/p>\n<p>        \/\/ \u904d\u5386\u6570\u7ec4&#xff0c;\u7edf\u8ba1 num1 \u548c num2 \u7684\u503c<br \/>\n        for (int i : arr) {<br \/>\n            \/\/ \u5982\u679c\u67d0\u4e2a ID \u51fa\u73b0\u7684\u6b21\u6570\u5927\u4e8e 2&#xff0c;\u8ba1\u7b97\u8d85\u51fa 2 \u7684\u90e8\u5206\u5e76\u7d2f\u52a0\u5230 num1<br \/>\n            if (i &gt; 2) {<br \/>\n                num1 &#043;&#061; i &#8211; 2;<br \/>\n            }<br \/>\n            \/\/ \u5982\u679c\u67d0\u4e2a ID \u53ea\u51fa\u73b0\u4e86 1 \u6b21&#xff0c;\u5c06 num2 \u52a0 1<br \/>\n            else if (i &#061;&#061; 1) {<br \/>\n                num2&#043;&#043;;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u6700\u7ec8\u7ed3\u679c\u53d8\u91cf<br \/>\n        int sum &#061; 0;<br \/>\n        \/\/ \u5f53 num1 \u5927\u4e8e num2 \u65f6&#xff0c;\u8bf4\u660e\u5df2\u88ab\u5360\u7528\u7684 ID \u6570\u91cf\u66f4\u591a&#xff0c;sum \u7b49\u4e8e num1<br \/>\n        if (num1 &gt; num2) {<br \/>\n            sum &#061; num1;<br \/>\n        }<br \/>\n        \/\/ \u5f53 num2 \u5927\u4e8e\u7b49\u4e8e num1 \u65f6&#xff0c;\u6309\u7167\u76f8\u5e94\u89c4\u5219\u8ba1\u7b97 sum<br \/>\n        else {<br \/>\n            sum &#061; num2 &#043; (num1 &#8211; num2) \/ 2;<br \/>\n        }<\/p>\n<p>        \/\/ \u8f93\u51fa\u6700\u7ec8\u7ed3\u679c<br \/>\n        System.out.println(sum);<br \/>\n        \/\/ \u5173\u95ed Scanner \u5bf9\u8c61&#xff0c;\u91ca\u653e\u8d44\u6e90<br \/>\n        scanner.close();<br \/>\n    }<br \/>\n}     <\/p>\n<h4>\u56db\u3001\u5408\u5e76\u6570\u5217<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u5c0f\u660e\u53d1\u73b0\u6709\u5f88\u591a\u65b9\u6848\u53ef\u4ee5\u628a\u4e00\u4e2a\u5f88\u5927\u7684\u6b63\u6574\u6570\u62c6\u6210\u82e5\u5e72\u6b63\u6574\u6570\u7684\u548c\u3002\u4ed6\u91c7\u53d6\u4e86\u5176\u4e2d\u4e24\u79cd\u65b9\u6848&#xff0c;\u5206\u522b\u5c06\u4ed6\u4eec\u5217\u4e3a\u4e24\u4e2a\u6570\u7ec4\u00a0{a1,a2,&#8230;,an}\u548c\u00a0{b1,b2,&#8230;,bm}\u3002\u4e24\u4e2a\u6570\u7ec4\u7684\u548c\u76f8\u540c\u3002<\/p>\n<p>\u5b9a\u4e49\u4e00\u6b21\u5408\u5e76\u64cd\u4f5c\u53ef\u4ee5\u5c06\u67d0\u6570\u7ec4\u5185\u76f8\u90bb\u7684\u4e24\u4e2a\u6570\u5408\u5e76\u4e3a\u4e00\u4e2a\u65b0\u6570&#xff0c;\u65b0\u6570\u7684\u503c\u662f\u539f\u6765\u4e24\u4e2a\u6570\u7684\u548c\u3002\u5c0f\u660e\u60f3\u901a\u8fc7\u82e5\u5e72\u6b21\u5408\u5e76\u64cd\u4f5c\u5c06\u4e24\u4e2a\u6570\u7ec4\u53d8\u6210\u4e00\u6a21\u4e00\u6837&#xff0c;\u5373\u00a0n&#061;m \u4e14\u5bf9\u4e8e\u4efb\u610f\u4e0b\u6807\u00a0i\u00a0\u6ee1\u8db3\u00a0ai&#061;bi\u3002\u8bf7\u8ba1\u7b97\u81f3\u5c11\u9700\u8981\u591a\u5c11\u6b21\u5408\u5e76\u64cd\u4f5c\u53ef\u4ee5\u5b8c\u6210\u5c0f\u660e\u7684\u76ee\u6807\u3002<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u8f93\u5165\u5171\u00a03\u00a0\u884c\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e3a\u4e24\u4e2a\u6b63\u6574\u6570\u00a0n,\u00a0m\u3002<\/p>\n<p>\u7b2c\u4e8c\u884c\u4e3a\u00a0n\u00a0\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570\u00a0a1,a2,&#8230;,an\u200b\u3002<\/p>\n<p>\u7b2c\u4e09\u884c\u4e3a\u00a0m\u00a0\u4e2a\u7531\u7a7a\u683c\u9694\u5f00\u7684\u6574\u6570\u00a0b1,b2,&#8230;,bm\u200b\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u8f93\u51fa\u5171\u00a01\u00a0\u884c&#xff0c;\u4e00\u4e2a\u6574\u6570\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  4 3<br \/>\n1 2 3 4<br \/>\n1 5 4<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  1<\/p>\n<p id=\"\u6837\u4f8b\u8bf4\u660e\">\u6837\u4f8b\u8bf4\u660e<\/p>\n<p>\u53ea\u9700\u8981\u5c06\u00a0a2\u200b\u00a0\u548c\u00a0a3\u00a0\u5408\u5e76&#xff0c;\u6570\u7ec4\u00a0a\u00a0\u53d8\u4e3a\u00a0{1,5,4}&#xff0c;\u5373\u548c\u00a0b\u00a0\u76f8\u540c\u3002<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e\u00a020% \u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n,\u00a0m\u226410^3\u3002<\/p>\n<p>\u5bf9\u4e8e\u00a0100% \u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n,\u00a0m\u226410^5&#xff0c;0&lt;ai,\u00a0bi\u226410^5\u3002<\/p>\n<p>\/\/ \u672c\u9898\u539f\u610f&#xff1a;\u201c\u4e24\u4e2a\u6570\u5217&#xff0c;\u901a\u8fc7\u4e0d\u65ad\u5408\u5e76\u76f8\u90bb\u7684\u4e24\u4e2a\u6570&#xff0c;\u4f7f\u4e24\u4e2a\u6570\u5217\u76f8\u540c\u201d \/\/ \u6ce8\u610f-\u201c\u76f8\u90bb\u201d \u201c\u5408\u5e76&#xff08;\u76f8\u52a0&#xff09;\u201d&#xff0c;\u4e5f\u5c31\u610f\u5473\u7740\u53ef\u80fd\u8981\u4f7f\u7528\u524d\u7f00\u548c\u3002 \/\/ \u7528\u53cd\u5411\u601d\u7ef4\u6765\u770b&#xff0c;\u4e24\u4e2a\u6570\u5217\u6700\u7ec8\u662f\u76f8\u540c\u7684\u3002 \/\/ \u4e5f\u5c31\u610f\u5473\u7740\u4ece\u4fe9\u6570\u5217&#xff0c;\u7b2c\u4e00\u4e2a\u6570\u5f00\u59cb&#xff0c;\u5c31\u8981\u662f\u76f8\u540c\u7684\u3002 \/\/ \u6211\u4eec\u53ea\u9700\u8981\u4ece\u5934\u5f00\u59cb\u8ba1\u7b97\u524d\u7f00\u548c&#xff0c;\u5982\u679c\u76f8\u540c\u65f6&#xff0c;\u4ee3\u8868\u4fe9\u6570\u5217\u7b2ci\u4f4d\u5df2\u7ecf\u76f8\u540c&#xff0c; \/\/ \u6b64\u65f6\u66f4\u65b0\u4fe9\u524d\u7f00\u548c\u7684\u8ba1\u7b97\u8d77\u59cb\u4f4d\u7f6e\u5373\u53ef\u3002 \/\/ \u6240\u4ee5\u672c\u9898\u662f&#xff0c;\u53cc\u6307\u9488\u4e0e\u524d\u7f00\u548c\u7684\u7ed3\u5408\u3002<\/p>\n<p> 1 2 3 4<br \/>\n1 5 4<br \/>\n&#8212;&#8212;&#8212;&#8212;<br \/>\n\u5bf9\u6bd4\u4e24\u4e2a\u6570\u5217\u7684\u7b2c\u4e00\u4f4d&#xff0c;\u76f8\u540c&#xff0c;\u4e0d\u7528\u53d8<br \/>\n&#8212;&#8212;&#8212;&#8212;<br \/>\n3 3 4<br \/>\n6 4<br \/>\n\u7b2c\u4e00\u4f4d\u4e0d\u540c&#xff0c;\u5408\u5e76\u5c0f\u7684\u524d\u4e24\u4f4d<br \/>\n&#8212;&#8212;&#8212;-<br \/>\n6 4<br \/>\n6 4<br \/>\n&#8230;. <\/p>\n<p>\/\/ \u672c\u9898\u53c8\u8ba9\u6211\u75db\u54ed\u4e0d\u5df2&#xff0c;\u7c7b\u578b\u5f00\u5c0f\u4e86&#xff0c;\u672c\u9898\u6700\u5927\u67091e10\u5de6\u53f3&#xff0c;int\u4e0d\u592a\u884c<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\nusing namespace std;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    int n,m;<br \/>\n    cin&gt;&gt;n&gt;&gt;m;<br \/>\n    vector&lt;int&gt; a(n,0);<br \/>\n    vector&lt;int&gt; b(m,0);<br \/>\n    for(int i&#061;0; i&lt;n; &#043;&#043;i) cin&gt;&gt;a[i];<br \/>\n    for(int i&#061;0; i&lt;m; &#043;&#043;i) cin&gt;&gt;b[i];<br \/>\n    \/\/ sum_a a\u6570\u5217\u7684\u524d\u7f00\u548c<br \/>\n    \/\/ sum_b b\u6570\u5217\u7684\u524d\u7f00\u548c<br \/>\n    \/\/ cnt_a a\u7684\u4f4d\u6570<br \/>\n    \/\/ cnt_b b\u7684\u4f4d\u6570<br \/>\n    \/\/ cnt_sum \u603b\u5171\u9700\u8981\u7684\u6b21\u6570<br \/>\n    long long sum_a&#061;0,sum_b&#061;0,cnt_a&#061;0,cnt_b&#061;0,cnt_sum&#061;0;<br \/>\n    while(true){<br \/>\n        if(sum_a&#061;&#061;sum_b){<br \/>\n            sum_a&#043;&#061;a[cnt_a&#043;&#043;];<br \/>\n            sum_b&#043;&#061;b[cnt_b&#043;&#043;];<br \/>\n        }else if(sum_a&lt;sum_b){ \/\/ \u7b2c\u4e00\u4e2a\u503c\u5c0f&#xff0c;\u9700\u8981\u5408\u5e76<br \/>\n            sum_a&#043;&#061;a[cnt_a&#043;&#043;];<br \/>\n            cnt_sum&#043;&#043;;<br \/>\n        }else if(sum_b&lt;sum_a){ \/\/ \u7b2c\u4e8c\u4e2a\u503c\u5c0f&#xff0c;\u9700\u8981\u5408\u5e76<br \/>\n            sum_b&#043;&#061;b[cnt_b&#043;&#043;];<br \/>\n            cnt_sum&#043;&#043;;<br \/>\n        }<br \/>\n        if(cnt_a&#061;&#061;n&amp;&amp;cnt_b&#061;&#061;m) break;<br \/>\n    }<br \/>\n    cout&lt;&lt;cnt_sum;<br \/>\n    return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> import java.util.Scanner;<\/p>\n<p>public class MergeArrays {<br \/>\n    public static void main(String[] args) {<br \/>\n        Scanner scanner &#061; new Scanner(System.in);<\/p>\n<p>        \/\/ \u8bfb\u53d6\u4e24\u4e2a\u6570\u7ec4\u7684\u957f\u5ea6<br \/>\n        int n &#061; scanner.nextInt();<br \/>\n        int m &#061; scanner.nextInt();<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u4e24\u4e2a\u6570\u7ec4<br \/>\n        int[] a &#061; new int[n];<br \/>\n        int[] b &#061; new int[m];<\/p>\n<p>        \/\/ \u8bfb\u53d6\u7b2c\u4e00\u4e2a\u6570\u7ec4\u7684\u5143\u7d20<br \/>\n        for (int i &#061; 0; i &lt; n; i&#043;&#043;) {<br \/>\n            a[i] &#061; scanner.nextInt();<br \/>\n        }<\/p>\n<p>        \/\/ \u8bfb\u53d6\u7b2c\u4e8c\u4e2a\u6570\u7ec4\u7684\u5143\u7d20<br \/>\n        for (int i &#061; 0; i &lt; m; i&#043;&#043;) {<br \/>\n            b[i] &#061; scanner.nextInt();<br \/>\n        }<\/p>\n<p>        \/\/ \u521d\u59cb\u5316\u524d\u7f00\u548c\u53d8\u91cf\u548c\u6307\u9488<br \/>\n        long sum_a &#061; 0, sum_b &#061; 0; \/\/ \u4f7f\u7528long\u907f\u514d\u5927\u6570\u6ea2\u51fa<br \/>\n        int cnt_a &#061; 0, cnt_b &#061; 0; \/\/ \u6570\u7ec4a\u548cb\u7684\u5f53\u524d\u6307\u9488\u4f4d\u7f6e<br \/>\n        int cnt_sum &#061; 0; \/\/ \u8bb0\u5f55\u5408\u5e76\u6b21\u6570<\/p>\n<p>        \/\/ \u5faa\u73af\u5904\u7406\u76f4\u5230\u4e24\u4e2a\u6570\u7ec4\u90fd\u904d\u5386\u5b8c\u6bd5<br \/>\n        while (true) {<br \/>\n            \/\/ \u5f53\u4e24\u4e2a\u524d\u7f00\u548c\u76f8\u7b49\u65f6&#xff0c;\u79fb\u52a8\u5230\u4e0b\u4e00\u4e2a\u5143\u7d20<br \/>\n            if (sum_a &#061;&#061; sum_b) {<br \/>\n                \/\/ \u6ce8\u610f\u8fb9\u754c\u6761\u4ef6&#xff1a;\u907f\u514d\u6570\u7ec4\u8d8a\u754c<br \/>\n                if (cnt_a &lt; n) {<br \/>\n                    sum_a &#043;&#061; a[cnt_a&#043;&#043;]; \/\/ \u79fb\u52a8a\u7684\u6307\u9488\u5e76\u7d2f\u52a0\u503c<br \/>\n                }<br \/>\n                if (cnt_b &lt; m) {<br \/>\n                    sum_b &#043;&#061; b[cnt_b&#043;&#043;]; \/\/ \u79fb\u52a8b\u7684\u6307\u9488\u5e76\u7d2f\u52a0\u503c<br \/>\n                }<br \/>\n            } else if (sum_a &lt; sum_b) {<br \/>\n                \/\/ a\u7684\u524d\u7f00\u548c\u8f83\u5c0f&#xff0c;\u9700\u8981\u5408\u5e76\u4e0b\u4e00\u4e2a\u5143\u7d20<br \/>\n                sum_a &#043;&#061; a[cnt_a&#043;&#043;]; \/\/ \u5408\u5e76a\u7684\u4e0b\u4e00\u4e2a\u5143\u7d20<br \/>\n                cnt_sum&#043;&#043;; \/\/ \u5408\u5e76\u6b21\u6570\u52a01<br \/>\n            } else {<br \/>\n                \/\/ b\u7684\u524d\u7f00\u548c\u8f83\u5c0f&#xff0c;\u9700\u8981\u5408\u5e76\u4e0b\u4e00\u4e2a\u5143\u7d20<br \/>\n                sum_b &#043;&#061; b[cnt_b&#043;&#043;]; \/\/ \u5408\u5e76b\u7684\u4e0b\u4e00\u4e2a\u5143\u7d20<br \/>\n                cnt_sum&#043;&#043;; \/\/ \u5408\u5e76\u6b21\u6570\u52a01<br \/>\n            }<\/p>\n<p>            \/\/ \u68c0\u67e5\u662f\u5426\u5df2\u7ecf\u904d\u5386\u5b8c\u4e24\u4e2a\u6570\u7ec4\u7684\u6240\u6709\u5143\u7d20<br \/>\n            if (cnt_a &#061;&#061; n &amp;&amp; cnt_b &#061;&#061; m) {<br \/>\n                break;<br \/>\n            }<br \/>\n        }<\/p>\n<p>        \/\/ \u8f93\u51fa\u6700\u7ec8\u7684\u5408\u5e76\u6b21\u6570<br \/>\n        System.out.println(cnt_sum);<br \/>\n        scanner.close();<br \/>\n    }<br \/>\n} <\/p>\n<h4>\u4e94\u3001\u6570\u4e09\u89d2<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u5c0f\u660e\u5728\u4e8c\u7ef4\u5750\u6807\u7cfb\u4e2d\u653e\u7f6e\u4e86\u00a0n\u00a0\u4e2a\u70b9&#xff0c;\u4ed6\u60f3\u5728\u5176\u4e2d\u9009\u51fa\u4e00\u4e2a\u5305\u542b\u4e09\u4e2a\u70b9\u7684\u5b50\u96c6&#xff0c;\u8fd9\u4e09\u4e2a\u70b9\u80fd\u7ec4\u6210\u4e09\u89d2\u5f62\u3002\u7136\u800c\u8fd9\u6837\u7684\u65b9\u6848\u592a\u591a\u4e86&#xff0c;\u4ed6\u51b3\u5b9a\u53ea\u9009\u62e9\u90a3\u4e9b\u53ef\u4ee5\u7ec4\u6210\u7b49\u8170\u4e09\u89d2\u5f62\u7684\u65b9\u6848\u3002\u8bf7\u5e2e\u4ed6\u8ba1\u7b97\u51fa\u4e00\u5171\u6709\u591a\u5c11\u79cd\u9009\u6cd5\u53ef\u4ee5\u7ec4\u6210\u7b49\u8170\u4e09\u89d2\u5f62&#xff1f;<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u8f93\u5165\u5171\u00a0n&#043;1 \u884c\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e3a\u4e00\u4e2a\u6b63\u6574\u6570\u00a0n\u3002<\/p>\n<p>\u540e\u9762\u00a0n\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e24\u4e2a\u6574\u6570\u00a0xi,\u00a0yi\u8868\u793a\u7b2c\u00a0i\u00a0\u4e2a\u70b9\u7684\u5750\u6807\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u8f93\u51fa\u5171 1\u00a0\u884c&#xff0c;\u4e00\u4e2a\u6574\u6570\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  5<br \/>\n1 1<br \/>\n4 1<br \/>\n1 0<br \/>\n2 1<br \/>\n1 2<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  4<\/p>\n<p id=\"\u6837\u4f8b\u8bf4\u660e\">\u6837\u4f8b\u8bf4\u660e<\/p>\n<p>\u4e00\u5171\u6709\u00a04\u00a0\u79cd\u9009\u6cd5:\u00a0{3,4,5}\u3001{1,3,4}\u3001{5,2,3}\u3001{1,4,5}\u3002<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e\u00a020% \u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n\u2264200\u3002<\/p>\n<p>\u5bf9\u4e8e\u00a0100% \u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n\u22642000&#xff0c;0\u2264xi,yi\u226410^9\u3002<\/p>\n<p>\/* \u00a0 \u672c\u9898\u8981\u662f\u76f4\u63a53\u5c42\u66b4\u529b&#xff0c;\u80af\u5b9a\u5bf9&#xff0c;\u4f46\u662f\u53ea\u80fd\u83b7\u53d660%\u7684\u5206&#xff01; \u00a0 \u6240\u4ee5\u8981\u7528\u4e0a\u5f88\u591a\u4f18\u5316\u65b9\u5f0f \u00a0 \u5982&#xff1a;\u6839\u636e\u534a\u5f84\u6c42\u89e3&#xff0c;\u53c9\u4e58(\u5728\u672c\u6587\u4e0b\u65b9\u6709\u8bb2\u89e3&#xff0c;\u4e5f\u53ef\u4e0a\u7f51\u641c)\u5224\u662f\u5426\u4e09\u70b9\u5728\u4e00\u6761\u76f4\u7ebf\u4e0a \u00a0 \u901a\u8fc7vector&lt;map&lt;ll,vector&lt;int&gt;&gt;&gt; \u9884\u5904\u7406\u5206\u7ec4\u3002 \u00a0 \u6700\u540e\u7528unordered_map\u5b58\u50a8&#xff0c;O(1)<\/p>\n<p>\u00a0 \u5176\u5b9e\u6700\u5f00\u59cb&#xff0c;\u6211\u4e5f\u662f\u6709\u7591\u95ee\u7684&#xff0c;\u8fd9\u662f\u600e\u4e48\u5c06O(n^3)\u4f18\u5316\u5230\u63a5\u8fd1O(n^2) \u00a0 \u6bd5\u7adf\u9884\u5904\u7406\u5206\u7ec4\u540e\u4e0b\u65b9\u4ecd\u67094\u5c42\u5faa\u73af\u5462 \u00a0 \u5176\u5b9e\u753b\u4e2a\u56fe\u5c31\u597d\u4e86\u3002 \u00a0 \u6ca1\u4f18\u5316\u4e4b\u524d&#xff0c;\u6bcf\u4e2a\u8282\u70b9\u90fd\u8981\u5224\u65ad(n^2)\u6b21,\u4f18\u5316\u4e4b\u540e&#xff0c;\u6bcf\u4e2a\u8282\u70b9\u4ec5\u9700\u5224\u65ad\u5206\u7ec4\u8fc7\u540e\u7684\u5c31\u884c(\u54ea\u6015\u662f4\u5c42&#xff0c;\u5176\u5b9e\u6709\u6548\u7684\u70b9\u4e0d\u591a&#xff0c;\u53ef\u8fd1\u4f3c\u6210\u7ebf\u6027)\u3002 *\/<\/p>\n<h5>\u00a0C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#include &lt;unordered_map&gt;<br \/>\nusing namespace std;<\/p>\n<p>#define ll long long \/\/ \u56e0\u4e3a\u4e0d\u53ef\u80fd\u51fa\u73b0\u8d1f\u6570&#xff0c;\u76f4\u63a5\u5f00\u5230\u6700\u5927(unsigned long long)<br \/>\nconst ll N &#061; 2e3&#043;5;<\/p>\n<p>struct point{<br \/>\n    int x;<br \/>\n    int y;<br \/>\n}p[N]; \/\/ \u5b9a\u4e49\u8282\u70b9-\u9884\u5904\u7406<\/p>\n<p>ll get_radius(int i, int j){ \/\/ \u534a\u5f84\u7684\u5e73\u65b9<br \/>\n    return (p[i].x-p[j].x)*(p[i].x-p[j].x) &#043; (p[i].y-p[j].y)*(p[i].y-p[j].y);<br \/>\n}<\/p>\n<p>bool is_parallel(int i, int j, int k){ \/\/ \u7528\u53c9\u4e58\u7684\u65b9\u6cd5&#xff0c;\u5feb\u901f\u5224\u65ad&#xff0c;\u8fd9\u4e00\u6b65\u4e0d\u4f1a\u7684&#xff0c;\u53ef\u4ee5\u4e0a\u7f51\u67e5\u8be2\u53c9\u4e58\u7684\u4f5c\u7528&#xff0c;\u4ee5\u53ca\u7528\u6cd5\u3002<br \/>\n    ll v &#061; (p[j].x-p[i].x)*(p[k].y-p[i].y)-(p[j].y-p[i].y)*(p[k].x-p[i].x); \/\/ i-j(p[j].x-p[i].x),(p[j].y-p[i].y) \u4e0e i-k(p[k].x-p[i].x),(p[k].y-p[i].y)<br \/>\n    if(v&#061;&#061;0) return true;<br \/>\n    else return false;<br \/>\n}<\/p>\n<p>int main(){<br \/>\n    int n;<br \/>\n    cin&gt;&gt;n;<br \/>\n    for(int i&#061;0; i&lt;n; &#043;&#043;i) cin&gt;&gt;p[i].x&gt;&gt;p[i].y;<br \/>\n    vector&lt;unordered_map&lt;ll,vector&lt;int&gt;&gt;&gt; vec(n); \/\/ \u5b58<br \/>\n    \/\/ \u9884\u5904\u7406&#xff0c;\u53ea\u9700\u8981\u8017\u65f6O(n^2)&#xff0c;\u5373\u53ef\u5206\u5806&#xff0c;\u907f\u514d3\u5c42\u66b4\u529b\u7684\u5927\u91cf\u91cd\u590d\u8ba1\u7b97<br \/>\n    for(int i&#061;0; i&lt;n; &#043;&#043;i){<br \/>\n        unordered_map&lt;ll,vector&lt;int&gt;&gt; m; \/\/ \u7528\u534a\u5f84\u7684\u5e73\u65b9\u50a8\u5b58&#xff0c;\u8fd9\u6837\u5c31\u4e0d\u7528\u5f00\u65b9\u4e86<br \/>\n        for(int j&#061;0; j&lt;n; &#043;&#043;j){<br \/>\n            if(i&#061;&#061;j) continue;<br \/>\n            ll len &#061; get_radius(i,j);<br \/>\n            m[len].push_back(j); \/\/ \u628a\u8fd9\u4e2a\u70b9\u5b58\u8fdb\u53bb<br \/>\n        }<br \/>\n        vec[i] &#061; m; \/\/ \u628amap\u5b58\u5165<br \/>\n    }\/\/ \u6700\u5927\u7684\u4f18\u70b9\u5c31\u662f\u907f\u514d\u4e86\u8bb8\u591a\u65e0\u610f\u4e49\u7684\u91cd\u590d\u8ba1\u7b97<\/p>\n<p>    int sum &#061; 0;<br \/>\n    for(int i&#061;0; i&lt;n; &#043;&#043;i){ \/\/ \u627e\u5230\u8fd9\u4e2a\u70b9&#xff0c;\u5224\u65ad\u5176\u5185\u90e8\u7684\u5b58\u50a8<br \/>\n        auto m &#061; vec[i]; \/\/ \u8fd9\u4e2a\u7684\u51fa\u6765\u7684\u77e5\u8bc6map\u7ed3\u5408&#xff0c;\u91cc\u9762\u5e7c\u5ae9\u591a<br \/>\n        for(auto it&#061;m.begin(); it!&#061;m.end(); &#043;&#043;it){<br \/>\n            vector&lt;int&gt; p_m &#061; it-&gt;second;<br \/>\n            if(p_m.size()&lt;&#061;1) continue; \/\/ \u8fd9\u79cd\u60c5\u51b5\u4e0b&#xff0c;\u8df3\u8fc7<br \/>\n            for(int j&#061;0; j&lt;p_m.size(); &#043;&#043;j){<br \/>\n                for(int k&#061;j&#043;1; k&lt;p_m.size(); &#043;&#043;k){<br \/>\n                    if(is_parallel(i,p_m[j],p_m[k])) continue; \/\/ \u5171\u7ebf<br \/>\n                    sum&#043;&#043;;<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n    }<br \/>\n    cout&lt;&lt;sum&lt;&lt;endl;<br \/>\n    return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> import java.util.*;<br \/>\npublic class Main {<br \/>\n    public static void main(String[] args) {<br \/>\n      \/\/\u8f93\u51fa\u90e8\u5206<br \/>\n        \/\/\u8bfb\u53d6\u8f93\u5165\u7684\u70b9&#xff0c;\u5e76\u7edf\u8ba1\u6bcf\u4e2a\u70b9\u7684\u51fa\u73b0\u6b21\u6570<br \/>\n        Scanner sc &#061; new Scanner(System.in);<br \/>\n        int n &#061; sc.nextInt();\/\/\u8f93\u5165\u70b9\u7684\u6570\u91cf<br \/>\n        int[] x &#061; new int [n &#043; 10];\/\/\u5b58\u50a8\u6bcf\u4e2a\u70b9\u7684x\u5750\u6807<br \/>\n        int[] y &#061; new int [n &#043; 10];\/\/\u5b58\u50a8\u6bcf\u4e2a\u70b9\u7684y\u5750\u6807<br \/>\n        HashMap&lt;String, Integer&gt; s &#061; new HashMap&lt;&gt;();\/\/\u7edf\u8ba1\u6bcf\u4e2a\u70b9\u7684\u51fa\u73b0\u6b21\u6570\/\/\u952e\u662f\u70b9\u7684\u5750\u6807&#xff0c;\u5982&#xff08;&#034;1 2&#034;)<br \/>\n        for(int i &#061; 0; i &lt; n; i&#043;&#043;){<br \/>\n          x[i] &#061; sc.nextInt();\/\/\u8f93\u5165\u7b2ci\u4e2a\u70b9\u7684x\u5750\u6807<br \/>\n          y[i] &#061; sc.nextInt();\/\/\u8f93\u5165\u7b2ci\u4e2a\u70b9\u7684y\u5750\u6807<br \/>\n          String t &#061; x[i] &#043; &#034; &#034; &#043; y[i];\/\/\u5c06\u5750\u6807\u62fc\u63a5\u6210\u5b57\u7b26\u4e32\u4f5c\u4e3a\u952e<br \/>\n          s.put(t, s.getOrDefault(t , 0) &#043; 1);\/\/\u7edf\u8ba1\u8bfb\u70b9\u7684\u51fa\u73b0\u6b21\u6570<br \/>\n        }<br \/>\n      \/\/\u8ba1\u7b97\u6838\u5fc3\u90e8\u5206<br \/>\n        \/\/\u5bf9\u4e8e\u6bcf\u4e2a\u70b9i&#xff0c;\u8ba1\u7b97\u5b83\u4e0e\u5176\u4ed6\u6240\u6709\u70b9j\u7684\u8ddd\u79bb&#xff0c;\u5e76\u5c06\u8ddd\u79bb\u76f8\u540c\u7684\u70b9\u5206\u7ec4<br \/>\n        long res &#061; 0;\/\/\u6700\u7ec8\u7ed3\u679c<br \/>\n        for(int i &#061; 0; i &lt; n; i&#043;&#043;){<br \/>\n          HashMap&lt; Long,List&lt;Integer&gt; &gt; map &#061; new HashMap&lt;&gt;();\/\/\u5b58\u50a8\u8ddd\u79bb\u76f8\u540c\u7684\u70b9\u7684\u7d22\u5f15<br \/>\n          for(int j &#061; 0; j &lt; n; j&#043;&#043;){<br \/>\n            if(i &#061;&#061; j) continue;\/\/\u8df3\u8fc7\u81ea\u5df1<br \/>\n            long d &#061; (long)(Math.pow(x[i] &#8211; x[j], 2) &#043; Math.pow(y[i] &#8211; y[j] , 2));\/\/\u8ba1\u7b97\u8ddd\u79bb\u7684\u5e73\u65b9<br \/>\n            List&lt;Integer&gt; list &#061; map.getOrDefault(d, new ArrayList&lt;&gt;());\/\/\u521d\u59cb\u5316\u5217\u8868<br \/>\n            list.add(j);\/\/\u5c06\u70b9j\u52a0\u5165\u5bf9\u5e94\u7684\u5217\u8868<br \/>\n            map.put(d,list);\/\/\u66f4\u65b0map<br \/>\n          }<br \/>\n  \/\/map\u662f\u4e00\u4e2a\u54c8\u5e0c\u8868&#xff0c;\u952e\u662f\u8ddd\u79bb\u7684\u5e73\u65b9&#xff08;d&#xff09;\u503c\u662f\u4e00\u4e2a\u5217\u8868&#xff0c;\u5b58\u50a8\u6240\u6709\u4e0e\u70b9i\u8ddd\u79bb\u4e3ad\u7684\u70b9\u7684\u7d22\u5f15<br \/>\n  \/\/d\u662f\u70b9i\u548c\u70b9j\u4e4b\u95f4\u7684\u8ddd\u79bb\u7684\u5e73\u65b9&#xff08;\u4e3a\u4e86\u8282\u7701\u8ba1\u7b97\u91cf&#xff0c;\u6ca1\u6709\u5f00\u5e73\u65b9&#xff09;<br \/>\n          for(long b : map.keySet()){<br \/>\n            List&lt;Integer&gt;list &#061; map.get(b);\/\/\u83b7\u53d6\u8ddd\u79bb\u4e3ab\u7684\u6240\u6709\u70b9<br \/>\n            res &#043;&#061; (list.size() * (list.size() &#8211; 1)) \/2;\/\/\u7edf\u8ba1\u70b9\u7684\u6570\u91cf<br \/>\n            long c &#061; 0;<br \/>\n            for(int j : list){<br \/>\n              long x3 &#061; 2 * x[i] &#8211; x[j], y3 &#061; 2 * y[i] &#8211; y[j];\/\/\u8ba1\u7b97\u5bf9\u79f0\u5e26\u70b9x\u4e0ey\u7684\u5750\u6807<br \/>\n              if(s.containsKey(x3 &#043; &#034; &#034; &#043; y3)){\/\/\u62fc\u63a5\u6210\u5b57\u7b26\u4e32<br \/>\n                c &#043;&#061; s.get(x3 &#043; &#034; &#034; &#043; y3);\/\/\u7edf\u8ba1\u5bf9\u79f0\u70b9\u7684\u51fa\u73b0\u6b21\u6570<br \/>\n              }<br \/>\n            }<br \/>\n            res -&#061; c\/2;\/\/\u51cf\u53bb\u91cd\u590d\u7edf\u8ba1\u7684\u70b9\u5bf9<br \/>\n          }<br \/>\n        }<br \/>\n        System.out.println(res);<br \/>\n    }<br \/>\n} <\/p>\n<h4>\u516d\u3001\u5220\u8fb9\u95ee\u9898<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5305\u542b\u00a0N\u00a0\u4e2a\u7ed3\u70b9\u00a0M\u00a0\u6761\u8fb9\u7684\u65e0\u5411\u56fe\u00a0G&#xff0c;\u7ed3\u70b9\u7f16\u53f7\u00a01&#8230;N\u3002\u5176\u4e2d\u6bcf\u4e2a\u7ed3\u70b9\u90fd\u6709\u4e00\u4e2a\u70b9\u6743\u00a0Wi\u200b\u3002<\/p>\n<p>\u4f60\u53ef\u4ee5\u4ece\u00a0M\u00a0\u6761\u8fb9\u4e2d\u4efb\u9009\u6070\u597d\u4e00\u6761\u8fb9\u5220\u9664&#xff0c;\u5982\u679c\u5269\u4e0b\u7684\u56fe\u6070\u597d\u5305\u542b\u00a02\u00a0\u4e2a\u8fde\u901a\u5206\u91cf&#xff0c;\u5c31\u79f0\u8fd9\u662f\u4e00\u79cd\u5408\u6cd5\u7684\u5220\u9664\u65b9\u6848\u3002<\/p>\n<p>\u5bf9\u4e8e\u4e00\u79cd\u5408\u6cd5\u7684\u5220\u9664\u65b9\u6848&#xff0c;\u6211\u4eec\u5047\u8bbe\u00a02\u00a0\u4e2a\u8fde\u901a\u5206\u91cf\u5305\u542b\u7684\u70b9\u7684\u6743\u503c\u4e4b\u548c\u5206\u522b\u4e3a\u00a0X\u548c\u00a0Y&#xff0c;\u8bf7\u4f60\u627e\u51fa\u4e00\u79cd\u4f7f\u5f97\u00a0X\u4e0e\u00a0Y\u00a0\u7684\u5dee\u503c\u6700\u5c0f\u7684\u65b9\u6848\u3002\u8f93\u51fa\u00a0X\u00a0\u4e0e\u00a0Y\u00a0\u7684\u5dee\u503c\u3002<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u7b2c\u4e00\u884c\u5305\u542b\u4e24\u4e2a\u6574\u6570\u00a0N\u00a0\u548c\u00a0M\u3002<\/p>\n<p>\u7b2c\u4e8c\u884c\u5305\u542b\u00a0N\u4e2a\u6574\u6570&#xff0c;W1,W2,&#8230;WN\u200b\u3002<\/p>\n<p>\u4ee5\u4e0b\u00a0M\u00a0\u884c\u6bcf\u884c\u5305\u542b\u00a02\u00a0\u4e2a\u6574\u6570\u00a0U\u00a0\u548c\u00a0V&#xff0c;\u4ee3\u8868\u7ed3\u70b9\u00a0U\u00a0\u548c\u00a0V\u4e4b\u95f4\u6709\u4e00\u6761\u8fb9\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u4e00\u4e2a\u6574\u6570\u4ee3\u8868\u6700\u5c0f\u7684\u5dee\u503c\u3002\u5982\u679c\u4e0d\u5b58\u5728\u5408\u6cd5\u7684\u5220\u9664\u65b9\u6848&#xff0c;\u8f93\u51fa\u00a0\u22121\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  4 4<br \/>\n10 20 30 40<br \/>\n1 2<br \/>\n2 1<br \/>\n2 3<br \/>\n3 4<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  20<\/p>\n<p id=\"\u6837\u4f8b\u8bf4\u660e\">\u6837\u4f8b\u8bf4\u660e<\/p>\n<p>\u7531\u4e8e\u00a01\u00a0\u548c\u00a02\u00a0\u4e4b\u95f4\u5b9e\u9645\u6709\u00a02\u00a0\u6761\u8fb9&#xff0c;\u6240\u4ee5\u5408\u6cd5\u7684\u5220\u9664\u65b9\u6848\u6709\u00a02\u00a0\u79cd&#xff0c;\u5206\u522b\u662f\u5220\u9664\u00a0(2,3)\u00a0\u4e4b\u95f4\u7684\u8fb9\u548c\u5220\u9664 (3,4)\u00a0\u4e4b\u95f4\u7684\u8fb9\u3002<\/p>\n<p>\u5220\u9664\u00a0(2,3)\u00a0\u4e4b\u95f4\u7684\u8fb9&#xff0c;\u5269\u4e0b\u7684\u56fe\u5305\u542b\u00a022\u00a0\u4e2a\u8fde\u901a\u5206\u91cf:\u00a0{1,2}\u00a0\u548c{3,4}&#xff0c;\u70b9\u6743\u548c\u5206\u522b\u662f\u00a030\u300170&#xff0c;\u5dee\u4e3a\u00a040\u3002<\/p>\n<p>\u5220\u9664\u00a0(3,4)\u00a0\u4e4b\u95f4\u7684\u8fb9&#xff0c;\u5269\u4e0b\u7684\u56fe\u5305\u542b\u00a022\u00a0\u4e2a\u8fde\u901a\u5206\u91cf: {1,2,3}\u00a0\u548c\u00a0{4}&#xff0c;\u70b9\u6743\u548c\u5206\u522b\u662f\u00a060\u300140&#xff0c;\u5dee\u4e3a\u00a020\u3002<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e\u00a020%\u00a0\u7684\u6570\u636e&#xff0c;1\u2264N,M\u226410000\u3002<\/p>\n<p>\u5bf9\u4e8e\u53e6\u5916\u00a020%\u7684\u6570\u636e&#xff0c;\u6bcf\u4e2a\u7ed3\u70b9\u7684\u5ea6\u6570\u4e0d\u8d85\u8fc7\u00a02\u3002<\/p>\n<p>\u5bf9\u4e8e\u00a0100% \u7684\u6570\u636e&#xff0c;1\u2264N,M\u2264200000&#xff0c;0\u2264Wi\u226410^9&#xff0c;1\u2264U,V\u2264N\u3002<\/p>\n<p> \/\/ \u672c\u9898\u4e3atarjan\u7b97\u6cd5\u7684\u53d8\u79cd&#xff0c;\u4e0d\u61c2\u7684&#xff0c;\u53ef\u4ee5\u5148\u641c\u4e00\u4e0b\u57fa\u672c\u7528\u6cd5&#xff08;\u6d89\u53ca\u56fe\u7684\u77e5\u8bc6&#xff09;&#xff0c;\u672c\u6587\u6700\u5e95\u90e8&#xff0c;\u4e5f\u6709\u4f18\u8d28\u89c6\u9891\u7684\u94fe\u63a5 \/* \u00a0 \u5176\u5b9e\u672c\u9898\u4e0d\u96be&#xff0c;\u53ea\u8981\u6709\u56fe\u7684\u57fa\u7840\u5c31\u884c&#8211;&#xff08;\u80fd\u770b\u61c2\u7b54\u6848\u7684\u524d\u63d0&#xff09; \u00a0 \u8fde\u901a\u5206\u91cf&#xff1a;\u56fe\u7684\u4e00\u4e2a\u5b50\u56fe&#xff0c;\u8fd9\u4e2a\u5b50\u56fe\u4e2d&#xff0c;\u4efb\u610f\u4e24\u70b9\u4e4b\u95f4&#xff0c;\u90fd\u5b58\u5728\u53ef\u8fbe\u8def\u5f84 \u00a0 \u7136\u540e\u5c31\u662f tarjan \u7b97\u6cd5&#xff08;\u61c2\u5f97\u53ef\u4ee5\u4e0d\u7528\u770b&#xff0c;\u5efa\u8bae\u5148\u770b\u89c6\u9891&#xff0c;\u77e5\u9053tarjan\u662f\u5565&#xff09; \u00a0 * \u00a0 \u00a0 \u7528dfn&#xff08;\u53d1\u73b0\u65f6\u95f4\u6233&#xff09;\u4e0elow&#xff08;\u6700\u4f4e\u53ef\u8fbe\u7956\u5148\u7684\u53d1\u73b0\u65f6\u95f4\u6233&#xff09;\u3002\u786e\u5207\u7684\u8bf4&#xff0c;\u4ed6\u4fe9\u90fd\u662f\u4e2a\u7f16\u53f7\u3002 \u00a0 \u00a0 \u7136\u540e\u7528cnt&#xff08;count&#xff09;\u8fd9\u4e2a\u8bbe\u7f6e\u65f6\u95f4\u6233\u3002\u6bcf\u6b21&#043;&#043;\u3002 \u00a0 \u00a0 &#8211;\u4ee5\u4e0a\u662ftarjan\u7b97\u6cd5\u6a21\u7248&#8211; \u00a0 \u00a0 \u5efa\u7acb\u4e00\u4e2a\u51fd\u6570tarjan(n,fa) \/\/ n\u662f\u73b0\u8282\u70b9&#xff0c;fa\u662f\u7236\u8282\u70b9&#xff0c;\u907f\u514d\u91cd\u590d\u7528\u7684 \u00a0 \u00a0 \u7136\u540e&#xff0c;\u9012\u5f52\u8c03\u7528\u6bcf\u4e2a\u73b0\u9636\u6bb5\u5b50\u8282\u70b9&#xff08;\u5927\u81f4\u4f1a\u5148\u5c06\u6240\u6709&#xff09; \u00a0 \u00a0 \u6b64\u65f6\u6709\u4e09\u79cd\u60c5\u51b5 \u00a0 \u00a0 \u00a0 1\u3001\u662f\u672a\u88ab\u904d\u5386\u8fc7\u7684\u65b0\u8282\u70b9 \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u8fd9\u65f6\u53ef\u4ee5\u7ee7\u7eed\u5411\u4e0b\u641c\u7d22&#xff0c;\u7b49\u56de\u9000\u5230\u8fd9\u91cc\u65f6&#xff0c; \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u66f4\u65b0\u4e00\u4e0blow\u503c&#xff0c;\u82e5\u679c\u73b0\u8282\u70b9\u7684dfn\u5c0f\u4e8e\u5b50\u8282\u70b9\u7684low\u503c(dfn&lt;low)&#xff0c;\u4ee3\u8868\u8fde\u901a\u4e24\u8282\u70b9\u7684\u8fb9\u80fd\u88ab\u5272\u53bb \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u4e3a\u4e86\u8ba1\u6570&#xff0c;\u53ef\u4ee5\u5728\u7ef4\u62a4\u4e00\u4e2aw\u96c6\u5408&#xff0c;\u7528\u4e8e\u50a8\u5b58\u4ee5\u672c\u8282\u70b9\u4e3a\u7ed3\u5c3e\u7684\u603b\u548c \u00a0 \u00a0 \u00a0 2\u3001\u904d\u5386\u5230\u4e86\u7236\u8282\u70b9 \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u53ef\u4ee5\u6beb\u4e0d\u72b9\u8c6b\u7684\u9000\u56de\u4e86&#xff09; \u00a0 \u00a0 \u00a0 3\u3001\u904d\u5386\u5230\u4e86\u975e\u7236\u8282\u70b9\u7684\u65e7\u8282\u70b9 \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u8fd9\u4e2a\u53ef\u662f\u66f4\u65b0low\u503c\u7684\u597d\u65f6\u5019 \u00a0 \u00a0 \u00a0 \u00a0 &#xff08;\u662f\u4e3a\u4e86\u7ed9&#xff0c;\u56de\u6eaf\u65f6&#xff0c;\u5224\u65ad\u662f\u5426\u80fd\u6784\u6210\u8054\u901a\u56fe \u00a0 \u00a0\u505a\u51c6\u5907 \u00a0 * \u00a0 \/\/ \u62d3\u5c55-\u4ece\u5272\u8fb9\u95ee\u9898 -&gt; \u5272\u70b9\u95ee\u9898 \u00a0 (\u5272\u70b9\u95ee\u9898\u65f6&#xff0c;\u9700\u8981\u5c06low\u5c0f\u4e8e\u7b49\u4e8edfn(low&lt;&#061;dfn) \u00a0 (\u4e3a\u5565&lt;&#061;\u4e2d&#xff0c;\u591a\u4e86\u4e2a\u7b49\u4e8e&#xff1f;\u56e0\u4e3a\u4e00\u65e6\u5220\u6389\u8fd9\u4e2a\u70b9&#xff0c;\u6574\u4e2a\u94fe\u5b50\u5c31\u4f1a\u65ad\u5f00&#xff0c;Java\u89e3\u6790\u4e0b\u65b9\u6709\u56fe\u89e3 *\/<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;cmath&gt;<br \/>\n#include &lt;vector&gt;<br \/>\n#define ll long long<br \/>\nusing namespace std;<br \/>\nconst ll N &#061; 1e6&#043;5;<br \/>\nconst ll maxn &#061; 0x3f3f3f3f3f3f3f3f; \/\/ \u5b9a\u4e49\u201c\u4f2a\u6700\u5927\u503c\u201d<br \/>\nll n,m,sum_value&#061;0,cnt&#061;0,ans&#061;maxn; \/\/ sum_value\u603b\u548c,cnt\u8ba1\u6570\u5668<\/p>\n<p>vector&lt;ll&gt; dfn(N,0),low(N,0);<br \/>\nvector&lt;int&gt; vec[N]; \/\/ \u5b9a\u4e49\u90bb\u63a5\u8868<br \/>\nvector&lt;ll&gt; value(N,0); \/\/ \u6bcf\u4e2a\u8282\u70b9\u7684\u6743\u503c<br \/>\nvector&lt;ll&gt; node_sum(N,0); \/\/ \u56de\u9000\u56de\u6765\u7684\u8282\u70b9\u603b\u548c<\/p>\n<p>void tarjan(int u, int fa){ \/\/ \u73b0\u8282\u70b9u\u3001\u7236\u8282\u70b9fa<br \/>\n    dfn[u]&#061;low[u]&#061;&#043;&#043;cnt;<br \/>\n    for(int v:vec[u]){<br \/>\n        if(dfn[v]&#061;&#061;0){   \/\/ \u6ca1\u904d\u5386\u8fc7<br \/>\n            tarjan(v,u);<br \/>\n            low[u] &#061; min(low[v],low[u]);<br \/>\n            if(dfn[u]&lt;low[v]) ans&#061;min(ans,abs(sum_value-2*value[v]));<br \/>\n            value[u] &#043;&#061; value[v];<br \/>\n        }else if(v!&#061;fa){<br \/>\n            low[u]&#061;min(low[u],low[v]);<br \/>\n        }<br \/>\n    }<br \/>\n}<\/p>\n<p>void slove(){ \/\/ \u4f5c\u4e3a\u4e2d\u8f6c\u7ad9<br \/>\n    cin&gt;&gt;n&gt;&gt;m;<br \/>\n    for(int i&#061;1; i&lt;&#061;n; &#043;&#043;i) cin&gt;&gt;value[i],sum_value&#043;&#061;value[i];<br \/>\n    for(int i&#061;0; i&lt;m; &#043;&#043;i){ \/\/ \u5c06\u65e0\u5411\u56fe\u5b58\u5165<br \/>\n        int r1,r2;<br \/>\n        cin&gt;&gt;r1&gt;&gt;r2;<br \/>\n        vec[r1].push_back(r2);<br \/>\n        vec[r2].push_back(r1);<br \/>\n    }<br \/>\n    \/\/ \u73b0\u5728\u5565\u90fd\u6709\u4e86<br \/>\n    tarjan(1,0);<br \/>\n    if(value[1]!&#061;sum_value) cout&lt;&lt;abs(sum_value-2*value[1])&lt;&lt;endl;<br \/>\n    else if(ans!&#061;maxn) cout&lt;&lt;ans&lt;&lt;endl;<br \/>\n    else cout&lt;&lt;-1&lt;&lt;endl;<br \/>\n}<\/p>\n<p>int main(){<br \/>\n    slove();<br \/>\n    return 0;<br \/>\n}<\/p>\n<h5>Java<\/h5>\n<p> import java.util.ArrayList;<br \/>\nimport java.util.List;<br \/>\nimport java.util.Scanner;<\/p>\n<p>public class Main {<br \/>\n    \/\/ \u5b9a\u4e49\u5e38\u91cf N \u4f5c\u4e3a\u6570\u7ec4\u5927\u5c0f<br \/>\n    static final long N &#061; (long) (1e6 &#043; 5);<br \/>\n    \/\/ \u5b9a\u4e49\u201c\u4f2a\u6700\u5927\u503c\u201d<br \/>\n    static final long maxn &#061; 0x3f3f3f3f3f3f3f3fL;<br \/>\n    \/\/ \u8282\u70b9\u6570\u91cf n&#xff0c;\u8fb9\u7684\u6570\u91cf m<br \/>\n    static long n, m;<br \/>\n    \/\/ \u6240\u6709\u8282\u70b9\u6743\u503c\u603b\u548c<br \/>\n    static long sum_value &#061; 0;<br \/>\n    \/\/ \u65f6\u95f4\u6233\u8ba1\u6570\u5668<br \/>\n    static long cnt &#061; 0;<br \/>\n    \/\/ \u5b58\u50a8\u6700\u7ec8\u7ed3\u679c<br \/>\n    static long ans &#061; maxn;<br \/>\n    \/\/ \u5b58\u50a8\u6bcf\u4e2a\u8282\u70b9\u7684\u53d1\u73b0\u65f6\u95f4\u6233<br \/>\n    static List&lt;Long&gt; dfn &#061; new ArrayList&lt;&gt;();<br \/>\n    \/\/ \u5b58\u50a8\u6bcf\u4e2a\u8282\u70b9\u80fd\u56de\u6eaf\u5230\u7684\u6700\u65e9\u7956\u5148\u7684\u53d1\u73b0\u65f6\u95f4\u6233<br \/>\n    static List&lt;Long&gt; low &#061; new ArrayList&lt;&gt;();<br \/>\n    \/\/ \u90bb\u63a5\u8868&#xff0c;\u5b58\u50a8\u56fe\u7684\u7ed3\u6784<br \/>\n    static List&lt;List&lt;Integer&gt;&gt; vec &#061; new ArrayList&lt;&gt;();<br \/>\n    \/\/ \u5b58\u50a8\u6bcf\u4e2a\u8282\u70b9\u7684\u6743\u503c<br \/>\n    static List&lt;Long&gt; value &#061; new ArrayList&lt;&gt;();<\/p>\n<p>    \/\/ Tarjan \u7b97\u6cd5\u6838\u5fc3\u51fd\u6570<br \/>\n    static void tarjan(int u, int fa) {<br \/>\n        \/\/ \u521d\u59cb\u5316\u5f53\u524d\u8282\u70b9\u7684\u53d1\u73b0\u65f6\u95f4\u6233\u548c\u6700\u65e9\u7956\u5148\u65f6\u95f4\u6233<br \/>\n        dfn.set(u, &#043;&#043;cnt);<br \/>\n        low.set(u, cnt);<br \/>\n        \/\/ \u904d\u5386\u5f53\u524d\u8282\u70b9\u7684\u6240\u6709\u90bb\u63a5\u8282\u70b9<br \/>\n        for (int v : vec.get(u)) {<br \/>\n            if (dfn.get(v) &#061;&#061; 0) { \/\/ \u5982\u679c\u90bb\u63a5\u8282\u70b9\u672a\u88ab\u8bbf\u95ee\u8fc7<br \/>\n                \/\/ \u9012\u5f52\u8c03\u7528 Tarjan \u7b97\u6cd5\u5904\u7406\u90bb\u63a5\u8282\u70b9<br \/>\n                tarjan(v, u);<br \/>\n                \/\/ \u66f4\u65b0\u5f53\u524d\u8282\u70b9\u7684\u6700\u65e9\u7956\u5148\u65f6\u95f4\u6233<br \/>\n                low.set(u, Math.min(low.get(u), low.get(v)));<br \/>\n                \/\/ \u5982\u679c\u5f53\u524d\u8282\u70b9\u7684\u53d1\u73b0\u65f6\u95f4\u6233\u5c0f\u4e8e\u90bb\u63a5\u8282\u70b9\u7684\u6700\u65e9\u7956\u5148\u65f6\u95f4\u6233&#xff0c;\u8bf4\u660e\u8be5\u8fb9\u662f\u5272\u8fb9<br \/>\n                if (dfn.get(u) &lt; low.get(v)) {<br \/>\n                    ans &#061; Math.min(ans, Math.abs(sum_value &#8211; 2 * value.get(v)));<br \/>\n                }<br \/>\n                \/\/ \u5c06\u90bb\u63a5\u8282\u70b9\u7684\u6743\u503c\u7d2f\u52a0\u5230\u5f53\u524d\u8282\u70b9<br \/>\n                value.set(u, value.get(u) &#043; value.get(v));<br \/>\n            } else if (v !&#061; fa) { \/\/ \u5982\u679c\u90bb\u63a5\u8282\u70b9\u5df2\u88ab\u8bbf\u95ee\u4e14\u4e0d\u662f\u7236\u8282\u70b9<br \/>\n                \/\/ \u66f4\u65b0\u5f53\u524d\u8282\u70b9\u7684\u6700\u65e9\u7956\u5148\u65f6\u95f4\u6233<br \/>\n                low.set(u, Math.min(low.get(u), low.get(v)));<br \/>\n            }<br \/>\n        }<br \/>\n    }<\/p>\n<p>    \/\/ \u4e3b\u5904\u7406\u51fd\u6570<br \/>\n    static void solve() {<br \/>\n        Scanner scanner &#061; new Scanner(System.in);<br \/>\n        \/\/ \u8bfb\u53d6\u8282\u70b9\u6570\u91cf\u548c\u8fb9\u7684\u6570\u91cf<br \/>\n        n &#061; scanner.nextLong();<br \/>\n        m &#061; scanner.nextLong();<br \/>\n        \/\/ \u521d\u59cb\u5316\u5217\u8868<br \/>\n        for (int i &#061; 0; i &lt;&#061; n; i&#043;&#043;) {<br \/>\n            dfn.add(0L);<br \/>\n            low.add(0L);<br \/>\n            value.add(0L);<br \/>\n            vec.add(new ArrayList&lt;&gt;());<br \/>\n        }<br \/>\n        \/\/ \u8bfb\u53d6\u6bcf\u4e2a\u8282\u70b9\u7684\u6743\u503c\u5e76\u8ba1\u7b97\u603b\u548c<br \/>\n        for (int i &#061; 1; i &lt;&#061; n; i&#043;&#043;) {<br \/>\n            value.set(i, scanner.nextLong());<br \/>\n            sum_value &#043;&#061; value.get(i);<br \/>\n        }<br \/>\n        \/\/ \u8bfb\u53d6\u8fb9\u7684\u4fe1\u606f\u5e76\u6784\u5efa\u90bb\u63a5\u8868<br \/>\n        for (int i &#061; 0; i &lt; m; i&#043;&#043;) {<br \/>\n            int r1 &#061; scanner.nextInt();<br \/>\n            int r2 &#061; scanner.nextInt();<br \/>\n            vec.get(r1).add(r2);<br \/>\n            vec.get(r2).add(r1);<br \/>\n        }<br \/>\n        \/\/ \u4ece\u8282\u70b9 1 \u5f00\u59cb\u8fdb\u884c Tarjan \u7b97\u6cd5<br \/>\n        tarjan(1, 0);<br \/>\n        \/\/ \u5982\u679c\u8282\u70b9 1 \u7684\u6743\u503c\u603b\u548c\u4e0d\u7b49\u4e8e\u6240\u6709\u8282\u70b9\u7684\u6743\u503c\u603b\u548c<br \/>\n        if (value.get(1) !&#061; sum_value) {<br \/>\n            System.out.println(Math.abs(sum_value &#8211; 2 * value.get(1)));<br \/>\n        } else if (ans !&#061; maxn) { \/\/ \u5982\u679c\u627e\u5230\u4e86\u5272\u8fb9<br \/>\n            System.out.println(ans);<br \/>\n        } else { \/\/ \u6ca1\u6709\u627e\u5230\u7b26\u5408\u6761\u4ef6\u7684\u5272\u8fb9<br \/>\n            System.out.println(-1);<br \/>\n        }<br \/>\n    }<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        \/\/ \u8c03\u7528\u4e3b\u5904\u7406\u51fd\u6570<br \/>\n        solve();<br \/>\n    }<br \/>\n} <\/p>\n<p>\u00a0\u62d3\u5c55&#xff08;\u5272\u70b9&#xff09;&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"329\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115450-68023d8af0fa6.png\" width=\"439\" \/>\u200b<\/p>\n<\/p>\n<h4>\u4e03\u3001AB\u8def\u7ebf<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u5c0f\u660e\u62ff\u4e86\u00a0n\u6761\u7ebf\u6bb5\u7ec3\u4e60\u6293\u5a03\u5a03\u3002\u4ed6\u5c06\u6240\u6709\u7ebf\u6bb5\u94fa\u5728\u6570\u8f74\u4e0a&#xff0c;\u7b2c\u00a0i\u00a0\u6761\u7ebf\u6bb5\u7684\u5de6\u7aef\u70b9\u5728\u00a0li\u200b&#xff0c;\u53f3\u7aef\u70b9\u5728\u00a0ri\u200b\u3002\u5c0f\u660e\u7528\u00a0m\u00a0\u4e2a\u533a\u95f4\u53bb\u6846\u8fd9\u4e9b\u7ebf\u6bb5&#xff0c;\u7b2c\u00a0i\u00a0\u4e2a\u533a\u95f4\u7684\u8303\u56f4\u662f [Li\u200b,\u00a0Ri\u200b]\u3002\u5982\u679c\u4e00\u4e2a\u7ebf\u6bb5\u6709\u00a0\u81f3\u5c11\u4e00\u534a\u00a0\u7684\u957f\u5ea6\u88ab\u5305\u542b\u5728\u67d0\u4e2a\u533a\u95f4\u5185&#xff0c;\u5219\u5c06\u5176\u89c6\u4e3a\u88ab\u8fd9\u4e2a\u533a\u95f4\u6846\u4f4f\u3002\u8bf7\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u533a\u95f4\u6846\u4f4f\u4e86\u591a\u5c11\u4e2a\u7ebf\u6bb5?<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u8f93\u5165\u5171 n&#043;m&#043;1\u00a0\u884c\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e3a\u4e24\u4e2a\u6b63\u6574\u6570\u00a0n,\u00a0m\u3002<\/p>\n<p>\u540e\u9762\u00a0n\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e24\u4e2a\u6574\u6570\u00a0li\u200b,\u00a0ri\u200b\u3002<\/p>\n<p>\u540e\u9762\u00a0m\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e24\u4e2a\u6574\u6570\u00a0Li\u200b,\u00a0Ri\u200b\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u8f93\u51fa\u5171\u00a0m\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e00\u4e2a\u6574\u6570\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  3 2<br \/>\n1 2<br \/>\n1 3<br \/>\n3 4<br \/>\n1 4<br \/>\n2 4<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  3<br \/>\n2<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e\u00a020%\u00a0\u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1 n,m\u226410^3\u3002<\/p>\n<p>\u5bf9\u4e8e 100%\u00a0\u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n,m\u226410^5&#xff0c;li\u200b&lt;ri\u200b&#xff0c;0&lt;li,ri,Li,Ri\u226410^6&#xff0c;max{ri\u200b\u2212li\u200b}\u2264min{Ri\u200b\u2212Li\u200b}.<\/p>\n<p>\/* \u00a0 \u00a0\u5ba1\u9898 \u201c\u5c0f\u84dd\u6700\u5c11\u8981\u8d70\u591a\u5c11\u6b65&#xff1f;\u201d&#xff0c;\u201c\u6700\u5c11\u201d \u00a0 \u00a0BFS\u5c31\u662f\u89e3\u51b3\u56fe-\u6700\u77ed\u8def\u5f84\u7684\u7279\u6548\u836f&#xff0c; \u00a0 \u00a0DFS\u6df1\u641c\u4e5f\u80fd\u641c\u5230&#xff0c;\u4f46\u4e0d\u4e00\u5b9a\u662f\u6700\u77ed\u7684&#xff0c;\u6df1\u641c\u66f4\u503e\u5411\u4e8e\u6392\u5217\u7ec4\u5408\u3001\u89e3\u6570\u72ec\u3001\u516b\u7687\u540e&#xff0c;\u8fd9\u79cd\u5c1d\u8bd5\u6027\u7684\u7b97\u6cd5\u3002 \u00a0 \u00a0\u597d\u4e86&#xff0c;\u786e\u5b9a\u672c\u9898\u7684\u57fa\u8c03&#xff0c;\u5c31\u662f\u5e7f\u641c<\/p>\n<p>\u00a0 \u00a0\u5728\u5f00\u59cb\u4e4b\u524d&#xff0c;\u8fd8\u9700\u8003\u8651\u4e00\u4e2a\u95ee\u9898&#xff0c;\u5c31\u662f\u66b4\u529b\u641c\u7d22\u5fc5\u7136\u4f1a\u8d85\u65f6&#xff0c;\u56e0\u6b64&#xff0c;\u679d\u51cf\u64cd\u4f5c&#xff0c;\u5fc5\u4e0d\u53ef\u5c11\u3002\u4e5f\u5c31\u662f\u8981\u5f15\u5165\u8bb0\u5fc6\u5316\u641c\u7d22\u3002 \u00a0 \u00a0\u8fd9\u4e2a\u65f6\u5019&#xff0c;\u5c31\u8981\u601d\u8003&#xff0c;\u7528\u4ec0\u4e48\u5b58\u50a8\u8bb0\u5fc6\u5316\u641c\u7d22 \u00a0 \u00a0\u6ce8\u610f\u672c\u9898 &#034;\u683c\u5b50\u6570&#xff0c;\u8981\u662fK\u7684\u500d\u6570&#xff0c;\u6240\u4ee5\u8fd9\u91cc\u6d89\u53ca\u5230\u4e86k&#034; \u00a0 \u00a0-used[i][j][k]; \u5176\u4e2dk\u6765\u50a8\u5b58\u8d70\u5230\u8fd9\u4e2a\u683c\u5f0f&#xff0c;\u8fde\u7eed\u8d70\u7684\u6b65\u6570\u3002 \u00a0 \u00a0\u6b65\u6570\u76f8\u540c\u65f6&#xff0c;\u4ee3\u8868\u8be5\u5730\u5740\u5df2\u7ecf\u88ab\u8d70\u8fc7\u3002\u76f8\u540c\u7684\u7b26\u53f7&#xff0c;\u76f8\u540c\u7684\u6b65\u6570&#xff0c;\u6240\u4ee5\u53ef\u4ee5\u76f4\u63a5\u8df3\u8fc7\u3002 \u00a0 \u00a0&#xff08;\u6ce8\u610f&#xff0c;\u8fd9\u91cc\u4e0d\u7528\u4e09\u7ef4\u6570\u7ec4\u6807\u8bb0&#xff0c;\u662f\u4f1a\u8d85\u65f6\u7684&#xff09;\u3002<\/p>\n<p>\u00a0 \u00a0\u6240\u4ee5\u672c\u9898\u7528queue\u5e7f\u641c\u3001used[i][j][k]\u8bb0\u5fc6\u5316\u641c\u7d22\u3001res[i][j][k]\u6807\u8bb0\u8d70\u7684\u8fd9\u4e2a\u4f4d\u7f6e&#xff0c;\u7528\u4e86\u591a\u5c11\u6b65\u3002 *\/<\/p>\n<h5>C&#043;&#043;\u00a0<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;queue&gt;<br \/>\nusing namespace std;<\/p>\n<p>const int N &#061; 1e3&#043;5;<br \/>\nconst int step &#061; 1e1&#043;5;<br \/>\nstruct node{<br \/>\n    int x;<br \/>\n    int y;<br \/>\n    int step;<br \/>\n};<br \/>\nint n,m,k;<br \/>\nqueue&lt;node&gt; q; \/\/ \u7528\u961f\u5217&#xff0c;\u5b9e\u73b0\u5e7f\u641c<br \/>\nbool used[N][N][step]; \/\/ \u9884\u5904\u7406<br \/>\nint res[N][N][step]; \/\/ \u8868\u793a&#xff0c;\u6bcf\u4e2a\u8282\u70b9&#xff0c;\u90fd\u5728\u90a3\u4e2a\u72b6\u6001\u8d70\u8fc7<br \/>\nchar grid[N][N];<\/p>\n<p>int xf[]&#061;{1,-1,0,0}; \/\/ \u7528\u6765\u8bb0\u5f55\u65b9\u5411\u7684\u6539\u53d8<br \/>\nint yf[]&#061;{0,0,1,-1};<\/p>\n<p>int BFS(){<br \/>\n    q.push({0,0,0}); \/\/ \u5c06\u7b2c\u4e00\u4e2a\u8282\u70b9\u5b58\u5165<\/p>\n<p>    while(!q.empty()){<br \/>\n        node u &#061; q.front(); q.pop(); \/\/ \u53d6\u51fa\u8be5\u8282\u70b9<br \/>\n        if(u.x&#061;&#061;n-1 &amp;&amp; u.y&#061;&#061;m-1) return res[u.x][u.y][u.step];<\/p>\n<p>        for(int i&#061;0; i&lt;4; &#043;&#043;i){<br \/>\n            int X &#061; u.x&#043;xf[i], Y &#061; u.y&#043;yf[i], st &#061; u.step&#043;1;<br \/>\n            if(X&lt;0||X&gt;&#061;n||Y&lt;0||Y&gt;&#061;m) continue; \/\/ \u51fa\u8fb9\u754c<br \/>\n            if(st&lt;k&amp;&amp;grid[X][Y]!&#061;grid[u.x][u.y]) continue;<br \/>\n            if(st&#061;&#061;k&amp;&amp;grid[X][Y]&#061;&#061;grid[u.x][u.y]) continue;<br \/>\n            st &#061; st%k; \/\/ \u65f6\u523b\u66f4\u65b0\u7740<br \/>\n            if(used[X][Y][st]) continue; \/\/ \u90fd\u662f\u66f4\u65b0\u4e4b\u540e&#xff0c;\u5728\u904d\u5386\u7684<br \/>\n            used[X][Y][st]&#061;true; \/\/ \u8868\u793a\u904d\u5386\u8fc7<br \/>\n            res[X][Y][st]&#061;res[u.x][u.y][u.step]&#043;1; \/\/ \u591a\u8d70\u4e86\u4e00\u6b65<br \/>\n            q.push({X,Y,st});<br \/>\n        }<br \/>\n    }<br \/>\n    return -1; \/\/ \u6b64\u65f6\u8fd8\u6ca1\u6709\u89e3\u91ca&#xff0c;\u53ea\u80fd\u8bf4\u660e\u4e00\u4ef6\u4e8b&#xff0c;\u904d\u5386\u5230\u5934\u4e86&#xff0c;\u6ca1\u6709\u7ed3\u679c\u3002<br \/>\n}<\/p>\n<p>int main(){<br \/>\n    \/\/ \u57fa\u672c\u5904\u7406<br \/>\n    cin&gt;&gt;n&gt;&gt;m&gt;&gt;k;<br \/>\n    string str;<br \/>\n    for(int i&#061;0; i&lt;n; &#043;&#043;i){<br \/>\n        cin&gt;&gt;str;<br \/>\n        for(int j&#061;0; j&lt;m; &#043;&#043;j) grid[i][j]&#061;str[j];<br \/>\n    }<br \/>\n    cout&lt;&lt;BFS();<br \/>\n    return 0;<br \/>\n}<\/p>\n<h5>Java<\/h5>\n<p> import java.math.BigInteger;<br \/>\nimport java.util.*;<\/p>\n<p>public class Main {<\/p>\n<p>    static long INF &#061; (long) 1e18;<\/p>\n<p>    public static void main(String[] args) {<br \/>\n        Scanner sc &#061; new Scanner(System.in);<br \/>\n        int n &#061; sc.nextInt();<br \/>\n        int m &#061; sc.nextInt();<br \/>\n        int k &#061; sc.nextInt();<br \/>\n        sc.nextLine();<br \/>\n        char[][] mg &#061; new char[n][m];<br \/>\n        for (int i &#061; 0; i &lt; n; i&#043;&#043;) {<br \/>\n            mg[i] &#061; sc.nextLine().toCharArray();<br \/>\n        }<br \/>\n        LinkedList&lt;Pair&gt; qu &#061; new LinkedList&lt;Pair&gt;();<br \/>\n        qu.add(new Pair(0, 0, 1));<br \/>\n        int[][] d &#061; new int[][] {{0,1},{1,0},{0,-1},{-1,0}};<br \/>\n        boolean[][][] visited &#061; new boolean[n][m][2 * k];<br \/>\n        for (int step &#061; 0; !qu.isEmpty(); step&#043;&#043;) {<br \/>\n            int num &#061; qu.size();<br \/>\n            for (int i &#061; 0; i &lt; num; i&#043;&#043;) {<br \/>\n                Pair pair &#061; qu.pollFirst();<br \/>\n                int px &#061; pair.x, py &#061; pair.y, pf &#061; pair.flag;<br \/>\n                if (visited[px][py][pf]) {<br \/>\n                    continue;<br \/>\n                }<br \/>\n                visited[px][py][pf] &#061; true;<br \/>\n                if (pair.x &#061;&#061; n &#8211; 1 &amp;&amp; pair.y &#061;&#061; m &#8211; 1) {<br \/>\n                    System.out.print(step);<br \/>\n                    return;<br \/>\n                }<br \/>\n                for (int j &#061; 0; j &lt; 4; j&#043;&#043;) {<br \/>\n                    int x &#061; px &#043; d[j][0];<br \/>\n                    int y &#061; py &#043; d[j][1];<br \/>\n                    int f &#061; (pf &#043; 1) % (2 * k);<br \/>\n                    if (x &gt;&#061; 0 &amp;&amp; x &lt; n &amp;&amp; y &gt;&#061; 0 &amp;&amp; y &lt; m) {<br \/>\n                        if (visited[x][y][f]) {<br \/>\n                            continue;<br \/>\n                        }<br \/>\n                        if (pf &lt; k &amp;&amp; mg[x][y] &#061;&#061; &#039;A&#039; || pf &gt;&#061; k &amp;&amp; mg[x][y] &#061;&#061; &#039;B&#039;) {<br \/>\n                            qu.addLast(new Pair(x, y, f));<br \/>\n                        }<br \/>\n                    }<br \/>\n                }<br \/>\n            }<br \/>\n        }<br \/>\n        System.out.print(-1);<br \/>\n    }<br \/>\n}<\/p>\n<p>class Pair {<br \/>\n    int x, y, flag;<\/p>\n<p>    public Pair(int x, int y, int flag) {<br \/>\n        super();<br \/>\n        this.x &#061; x;<br \/>\n        this.y &#061; y;<br \/>\n        this.flag &#061; flag;<br \/>\n    }<br \/>\n} <\/p>\n<h4>\u516b\u3001\u6293\u5a03\u5a03<\/h4>\n<p id=\"\u95ee\u9898\u63cf\u8ff0\">\u95ee\u9898\u63cf\u8ff0<\/p>\n<p>\u5c0f\u660e\u62ff\u4e86\u00a0n\u00a0\u6761\u7ebf\u6bb5\u7ec3\u4e60\u6293\u5a03\u5a03\u3002\u4ed6\u5c06\u6240\u6709\u7ebf\u6bb5\u94fa\u5728\u6570\u8f74\u4e0a&#xff0c;\u7b2c\u00a0i\u00a0\u6761\u7ebf\u6bb5\u7684\u5de6\u7aef\u70b9\u5728\u00a0li\u200b&#xff0c;\u53f3\u7aef\u70b9\u5728\u00a0ri\u3002\u5c0f\u660e\u7528\u00a0m\u00a0\u4e2a\u533a\u95f4\u53bb\u6846\u8fd9\u4e9b\u7ebf\u6bb5&#xff0c;\u7b2c\u00a0i\u00a0\u4e2a\u533a\u95f4\u7684\u8303\u56f4\u662f [Li\u200b,\u00a0Ri\u200b]\u3002\u5982\u679c\u4e00\u4e2a\u7ebf\u6bb5\u6709\u00a0\u81f3\u5c11\u4e00\u534a\u00a0\u7684\u957f\u5ea6\u88ab\u5305\u542b\u5728\u67d0\u4e2a\u533a\u95f4\u5185&#xff0c;\u5219\u5c06\u5176\u89c6\u4e3a\u88ab\u8fd9\u4e2a\u533a\u95f4\u6846\u4f4f\u3002\u8bf7\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u533a\u95f4\u6846\u4f4f\u4e86\u591a\u5c11\u4e2a\u7ebf\u6bb5?<\/p>\n<p id=\"\u8f93\u5165\u683c\u5f0f\">\u8f93\u5165\u683c\u5f0f<\/p>\n<p>\u8f93\u5165\u5171 n&#043;m&#043;1\u00a0\u884c\u3002<\/p>\n<p>\u7b2c\u4e00\u884c\u4e3a\u4e24\u4e2a\u6b63\u6574\u6570\u00a0n,\u00a0m\u3002<\/p>\n<p>\u540e\u9762\u00a0n\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e24\u4e2a\u6574\u6570\u00a0li\u200b,\u00a0ri\u200b\u3002<\/p>\n<p>\u540e\u9762\u00a0m\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e24\u4e2a\u6574\u6570\u00a0Li\u200b,\u00a0Ri\u200b\u3002<\/p>\n<p id=\"\u8f93\u51fa\u683c\u5f0f\">\u8f93\u51fa\u683c\u5f0f<\/p>\n<p>\u8f93\u51fa\u5171\u00a0m\u00a0\u884c&#xff0c;\u6bcf\u884c\u4e00\u4e2a\u6574\u6570\u3002<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u5165\">\u6837\u4f8b\u8f93\u5165<\/p>\n<p>  3 2<br \/>\n1 2<br \/>\n1 3<br \/>\n3 4<br \/>\n1 4<br \/>\n2 4<\/p>\n<p id=\"\u6837\u4f8b\u8f93\u51fa\">\u6837\u4f8b\u8f93\u51fa<\/p>\n<p>  3<br \/>\n2<\/p>\n<p id=\"\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a\">\u8bc4\u6d4b\u7528\u4f8b\u89c4\u6a21\u4e0e\u7ea6\u5b9a<\/p>\n<p>\u5bf9\u4e8e\u00a020%\u00a0\u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n,m\u226410^3\u3002<\/p>\n<p>\u5bf9\u4e8e\u00a0100%\u00a0\u7684\u6570\u636e&#xff0c;\u4fdd\u8bc1\u00a0n,m\u226410^5&#xff0c;li\u200b&lt;ri\u200b&#xff0c;0&lt;li,ri,Li,Ri\u226410^6&#xff0c;max{ri\u200b\u2212li\u200b}\u2264min{Ri\u200b\u2212Li\u200b}.<\/p>\n<p>\/\/ \u806a\u660e\u7684\u4f60&#xff0c;\u4e00\u5b9a\u7528\u7684\u66b4\u529b&#xff0c;\u806a\u660e\u7684\u4f60&#xff0c;\u4e00\u5b9a\u8d85\u65f6o(*&#xffe3;\u25bd&#xffe3;*)\u30d6\u00a0 \/\/ \u672c\u9898&#xff0c;\u7528\u5dee\u5206&#043;\u524d\u7f00\u548c&#xff0c;\u5c31\u80fd\u975e\u5e38\u5b8c\u7f8e\u7684\u89e3\u51b3\u95ee\u9898 \/\/ \u6b64\u5916&#xff0c;\u672c\u9898\u9884\u5904\u7406\u5316\u7684\u65f6\u5019&#xff0c;\u4e00\u5b9a\u8981\u770b\u6e05\u695a&#xff01; \/\/ \u4e0d\u8981\u5904\u7406\u62102e5&#043;5\u4e86&#xff0c;\u8981\u5f00r\u3001l\u3001R\u3001L\u3002\u800c\u4e0d\u662fn,m;<\/p>\n<h5>C&#043;&#043;<\/h5>\n<p> #include &lt;iostream&gt;<br \/>\n#include &lt;vector&gt;<br \/>\nconst int N &#061; 2e6&#043;5;<br \/>\nusing namespace std;<\/p>\n<p>int main()<br \/>\n{<br \/>\n    int n,m;<br \/>\n    cin&gt;&gt;n&gt;&gt;m;<br \/>\n    vector&lt;int&gt; res(N,0);<br \/>\n    for(int i&#061;0,r,l; i&lt;n; &#043;&#043;i) cin&gt;&gt;l&gt;&gt;r,res[r&#043;l]&#043;&#043;;<br \/>\n    for(int i&#061;1; i&lt;N; &#043;&#043;i) res[i]&#043;&#061;res[i-1];<br \/>\n    for(int i&#061;1,L,R; i&lt;&#061;m; &#043;&#043;i){<br \/>\n        cin&gt;&gt;L&gt;&gt;R;<br \/>\n        L*&#061;2,R*&#061;2;<br \/>\n        if(L&#061;&#061;0) cout&lt;&lt;res[R]&lt;&lt;endl;<br \/>\n        else cout&lt;&lt;res[R]-res[L-1]&lt;&lt;endl;<br \/>\n    }<br \/>\n    return 0;<br \/>\n} <\/p>\n<h5>Java<\/h5>\n<p> import java.util.Scanner;<\/p>\n<p>public class SegmentQuery {<br \/>\n    public static void main(String[] args) {<br \/>\n        \/\/ \u5b9a\u4e49\u5e38\u91cf N&#xff0c;\u7528\u4e8e\u6570\u7ec4\u5927\u5c0f<br \/>\n        final int N &#061; 2000005;<br \/>\n        Scanner scanner &#061; new Scanner(System.in);<br \/>\n        \/\/ \u8bfb\u53d6 n \u548c m \u7684\u503c<br \/>\n        int n &#061; scanner.nextInt();<br \/>\n        int m &#061; scanner.nextInt();<br \/>\n        \/\/ \u521b\u5efa\u957f\u5ea6\u4e3a N \u7684\u6570\u7ec4 res \u5e76\u521d\u59cb\u5316\u4e3a 0<br \/>\n        int[] res &#061; new int[N];<br \/>\n        \/\/ \u8bfb\u53d6 n \u6761\u7ebf\u6bb5\u7684\u5de6\u53f3\u7aef\u70b9\u4fe1\u606f<br \/>\n        for (int i &#061; 0; i &lt; n; i&#043;&#043;) {<br \/>\n            int l &#061; scanner.nextInt();<br \/>\n            int r &#061; scanner.nextInt();<br \/>\n            \/\/ \u5bf9\u7ebf\u6bb5\u4e2d\u70b9\u5bf9\u5e94\u7684\u6570\u7ec4\u5143\u7d20\u52a0 1<br \/>\n            res[l &#043; r]&#043;&#043;;<br \/>\n        }<br \/>\n        \/\/ \u6784\u5efa\u524d\u7f00\u548c\u6570\u7ec4<br \/>\n        for (int i &#061; 1; i &lt; N; i&#043;&#043;) {<br \/>\n            res[i] &#043;&#061; res[i &#8211; 1];<br \/>\n        }<br \/>\n        \/\/ \u5904\u7406 m \u4e2a\u67e5\u8be2\u533a\u95f4<br \/>\n        for (int i &#061; 1; i &lt;&#061; m; i&#043;&#043;) {<br \/>\n            int L &#061; scanner.nextInt();<br \/>\n            int R &#061; scanner.nextInt();<br \/>\n            \/\/ \u5c06\u67e5\u8be2\u533a\u95f4\u7684\u5de6\u53f3\u7aef\u70b9\u4e58\u4ee5 2<br \/>\n            L *&#061; 2;<br \/>\n            R *&#061; 2;<br \/>\n            int result;<br \/>\n            \/\/ \u5904\u7406\u5de6\u7aef\u70b9\u4e3a 0 \u7684\u8fb9\u754c\u60c5\u51b5<br \/>\n            if (L &#061;&#061; 0) {<br \/>\n                result &#061; res[R];<br \/>\n            } else {<br \/>\n                result &#061; res[R] &#8211; res[L &#8211; 1];<br \/>\n            }<br \/>\n            \/\/ \u8f93\u51fa\u7ed3\u679c<br \/>\n            System.out.println(result);<br \/>\n        }<br \/>\n        scanner.close();<br \/>\n    }<br \/>\n}     <\/p>\n<p>\u540e\u9762\u7684\u4e24\u9053\u9898&#xff0c;\u54b1\u65f6\u95f4\u6709\u9650&#xff0c;\u5c31\u5148\u8df3\u8fc7\u5566(&#xff5e;&#xffe3;\u25bd&#xffe3;)&#xff5e;<\/p>\n<p>\u7b49\u540e\u7eed\u6253\u56fd\u8d5b\u65f6&#xff0c;\u5728\u62d0\u56de\u6765\u5199\u5199\u3002<\/p>\n<p>\u5f53\u7136\u5927\u5bb6\u6709\u597d\u7684\u4ee3\u7801\u3001\u89e3\u6790&#xff0c;\u4e5f\u53ef\u4ee5\u53d1\u7ed9\u6211&#xff0c;\u8ba9\u6211\u7785\u7785\u3002( \u2022\u0300 \u03c9 \u2022\u0301 )\u2727&#xff0c;\u6211\u8d34\u4e0a\u53bb\u3002<\/p>\n<\/p>\n<h4><span style=\"color:#1c7892\">\u77e5\u8bc6\u70b9&#xff1a;<\/span><\/h4>\n<h5><span style=\"color:#ad720d\">\u4e00\u3001\u5411\u91cf\u3001\u70b9\u4e58\u3001\u53c9\u4e58<\/span><\/h5>\n<p><span style=\"color:#ad720d\">&#xff08;AI\u6574\u7406&#xff09;<\/span><\/p>\n<h6><span style=\"color:#511b78\">1\u3001\u5411\u91cf&#xff1a;<\/span><\/h6>\n<h6><span style=\"color:#be191c\">\u7531\u6765&#xff1a;<\/span><\/h6>\n<p>\u65e9\u5728\u53e4\u5e0c\u814a\u65f6\u671f&#xff0c;\u6570\u5b66\u5bb6\u4e0e\u7269\u7406\u5b66\u5bb6\u5df2\u7ecf\u610f\u8bc6\u5230\u67d0\u4e9b\u91cf&#xff08;\u5982\u529b\u3001\u901f\u5ea6&#xff09;\u517c\u5177\u5927\u5c0f\u548c\u65b9\u5411\u3002\u6b64\u65f6 \u5df2\u7ecf\u8574\u542b\u4e86\u5411\u91cf&#xff0c;\u4f46\u6b64\u65f6\u5e76\u672a\u5f62\u6210\u660e\u786e\u7684\u6982\u5ff5\u4e0e\u7406\u8bba\u3002<\/p>\n<p>17\u4e16\u7eaa\u7b1b\u5361\u5c14\u521b\u5efa\u89e3\u6790\u51e0\u4f55\u540e&#xff0c;\u70b9\u7684\u4f4d\u7f6e\u53ef\u7528\u5750\u6807\u6765\u8868\u793a&#xff0c;\u7ebf\u6bb5\u7684\u957f\u5ea6\u548c\u65b9\u5411\u53ef\u901a\u8fc7\u5750\u6807\u5dee\u91cf\u5316\u3002 \u8fd9\u4e3a\u5411\u91cf\u7684\u4ee3\u6570\u8868\u8fbe&#xff0c;\u5960\u5b9a\u4e86\u57fa\u7840\u3002<\/p>\n<p>\u540e\u6765\u7ecf\u8fc7\u8d1f\u6570\u3001\u56db\u5143\u6570\u7684\u542f\u53d1\u3001\u7ebf\u6027\u6269\u5f20\u8bba&#8230;\u7b49\u51e0\u4ee3\u4eba\u52aa\u529b\u4e0e\u77e5\u8bc6\u7684\u8fed\u4ee3&#xff0c;\u5411\u91cf\u624d\u6700\u7ec8\u522b\u786e\u5b9a\u4e0b\u6765\u3002<\/p>\n<h6><span style=\"color:#be191c\">\u5b9a\u4e49&#xff1a;<\/span><\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"100\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8b666ef.png\" width=\"448\" \/>\u200b<\/p>\n<h6><span style=\"color:#be191c\">\u57fa\u672c\u5c5e\u6027&#xff1a;<\/span><\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"100\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8b7477c.png\" width=\"555\" \/>\u200b<\/p>\n<h6><span style=\"color:#be191c\">\u5e38\u89c1\u8fd0\u7b97&#xff1a;<\/span><\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"150\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8b82b7b.png\" width=\"591\" \/>\u200b<\/p>\n<h6><span style=\"color:#511b78\">2\u3001\u70b9\u4e58&#xff1a;<\/span><\/h6>\n<p>\u4e0d\u8981\u95ee&#xff0c;\u4e3a\u5565\u53eb\u70b9\u4e58&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u53ef\u7231\u7684\u95ee\u9898 &#8211;&gt; \u56e0\u4e3a\u4e24\u5411\u91cf\u4e4b\u95f4\u7528 \u201c\u70b9\u53f7\u201d \u76f8\u4e58\u3002<\/p>\n<h6><span style=\"color:#be191c\">\u5b9a\u4e49&#xff1a;<\/span><\/h6>\n<p>\u4e24\u5411\u91cf\u4e4b\u95f4\u76f8\u4e58&#xff0c;\u7ed3\u679c\u4e3a\u6807\u91cf\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"98\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8b9355f.png\" width=\"503\" \/>\u200b<\/p>\n<h6><span style=\"color:#be191c\">\u5e94\u7528&#xff1a;<\/span><\/h6>\n<ul>\n<li>\u5224\u65ad\u4e24\u6761\u8fb9\u4e4b\u95f4&#xff0c;\u662f\u949d\u89d2&#xff08;\u8d1f\u6570&#xff09;\u3001\u76f4\u89d2&#xff08;0&#xff09;\u3001\u8fd8\u662f\u9510\u89d2&#xff08;\u6b63\u6570&#xff09;<\/li>\n<li>\u4e00\u6761\u8fb9\u5728\u53e6\u4e00\u6761\u8fb9\u4e0a\u6620\u5c04\u7684\u957f\u5ea6\u3002<\/li>\n<li>\u8ba1\u7b97\u529b\u7684\u505a\u529f\u3002<\/li>\n<\/ul>\n<h6><span style=\"color:#511b78\">3\u3001\u53c9\u4e58&#xff1a;<\/span><\/h6>\n<p>\u4e5f\u4e0d\u8981\u95ee&#xff0c;\u4e3a\u5565\u53eb\u53c9\u4e58&#xff0c;\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u53ef\u7231\u7684\u95ee\u9898 &#8211;&gt; \u56e0\u4e3a\u4e24\u5411\u91cf\u4e4b\u95f4\u7528 \u201c\u53c9\u53f7\u201d \u76f8\u4e58\u3002<\/p>\n<h6><span style=\"color:#be191c\">\u4e8c\u7ef4&#xff1a;<\/span><\/h6>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"382\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8ba1012.png\" width=\"801\" \/>\u200b<\/p>\n<h6><span style=\"color:#be191c\">\u4e09\u7ef4&#xff1a;<\/span><\/h6>\n<h6><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"420\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8bc232a.png\" width=\"795\" \/>\u200b<span style=\"color:#be191c\">\u5e94\u7528&#xff1a;<\/span><\/h6>\n<p><span style=\"color:#be191c\">\u5207\u8bb0&#xff0c;\u5224\u65ad\u70b9\u65f6&#xff0c;\u53c9\u4e58\u8fb9\u7684\u65b9\u5411\u5f88\u91cd\u8981\u3002\u70b9\u7684\u90a3\u6761\u8fb9&#xff0c;\u653e\u5728\u7b2c\u4e8c\u4e2a\u3002<\/span><\/p>\n<p>\u6c42\u5e73\u884c\u56db\u8fb9\u5f62\u4e0e\u4e09\u89d2\u5f62\u7684\u9762\u79ef&#xff1a;<\/p>\n<p>\u4e8c\u7ef4 \u4e24\u5411\u91cf\u53c9\u4e58&#xff0c;\u6c42\u7684\u662f\u5e73\u884c\u56db\u8fb9\u5f62\u7684\u9762\u79ef\u3002\u9664\u4e8e2&#xff0c;\u6c42\u7684\u662f\u4e09\u89d2\u5f62\u3002<\/p>\n<p>\u70b9\u4e0e\u76f4\u7ebf\u7684\u5173\u7cfb&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"191\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115451-68023d8be4243.png\" width=\"788\" \/>\u200b<\/p>\n<p>\u7ebf\u6bb5\u76f8\u4ea4\u7684\u68c0\u6d4b&#xff1a;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"64\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115452-68023d8c08bf1.png\" width=\"774\" \/>\u200b<\/p>\n<p>\u70b9\u4e0e\u76f4\u7ebf\u5173\u7cfb&#xff0c;\u8be6\u89e3&#xff01;&#xff01;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"318\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115452-68023d8c1ab1d.png\" width=\"608\" \/>\u200b<\/p>\n<\/p>\n<h4><span style=\"color:#ad720d\">\u4e8c\u3001\u6d6e\u70b9\u6570\u6bd4\u8f83<\/span><\/h4>\n<p>\u5728\u7f16\u7a0b\u4e2d&#xff0c;\u901a\u5e38\u4e0d\u7528&#061;&#061;\u53f7&#xff0c;\u6765\u8fdb\u884c\u6d6e\u70b9\u6570\u6bd4\u8f83\u3002\u56e0\u4e3a\u4f1a\u51fa\u73b0\u7cbe\u5ea6\u8bef\u5dee\u3002\u5373\u4fbf\u5728\u6570\u5b66\u4e2d\u76f8\u7b49&#xff0c;\u5728\u8ba1\u7b97\u673a\u4e2d\u4e5f\u4e0d\u4e00\u5b9a\u76f8\u7b49\u3002<\/p>\n<p> abs(a-b)&lt;1e-6 <\/p>\n<p>\u901a\u5e38\u7528\u5c0f\u4e8e1e-6\u6765\u6d4b\u8bd5\u5dee\u503c\u3002<\/p>\n<p>1e-6\u5728\u901a\u5e38\u60c5\u51b5\u4e0b\u662f\u591f\u7528\u7684&#xff0c; \u5b83\u65e2\u4e0d\u662f\u90a3\u4e48\u4e25\u683c&#xff08;\u628a\u672c\u5e94\u8be5\u76f8\u540c\u7684\u6570&#xff0c;\u5224\u4e3a\u4e0d\u540c&#xff09; \u5b83\u4e5f\u4e0d\u662f\u90a3\u4e48\u5bbd\u677e&#xff08;\u628a\u672c\u4e0d\u540c\u7684\u6570&#xff0c;\u5224\u4e3a\u76f8\u540c&#xff09;<\/p>\n<\/p>\n<h4><span style=\"color:#ad720d\">\u4e09\u3001map\u4e0eunordered_map<\/span><\/h4>\n<p>map\u5e95\u5c42\u4e3a\u7ea2\u9ed1\u6811&#xff0c;unordered_map\u5e95\u5c42\u4e3a\u54c8\u5e0c\u8868<\/p>\n<p>\u5b58or\u53d6&#xff0c;map(O(logN))\u7684\u6548\u7387\u7686\u4f4e\u4e8eunordered_map(O(1))\u3002<\/p>\n<\/p>\n<h4><span style=\"color:#ad720d\">\u56db\u3001\u6781\u5927\u503c&#xff08;32\u4f4d\u300164\u4f4d\u300116\u8fdb\u5236&#xff09;<\/span><\/h4>\n<ul>\n<li>INT32_MAX\u00a0\u662f 32 \u4f4d\u6709\u7b26\u53f7\u6574\u6570\u7684\u6700\u5927\u503c&#xff0c;\u4e3a\u00a02,147,483,647\u3002&#xff08;2.15 \u00d7 10\u2079&#xff09;<\/li>\n<li>0x3f3f3f3f3f3f3f3f&#xff1a;\u8f6c\u6362\u4e3a\u5341\u8fdb\u5236\u4e3a&#xff1a;1,082,367,756,170,655,743\u3002&#xff08;\u7ea6 1.08 \u00d7 10\u00b9\u2078&#xff09;<\/li>\n<li>INT64_MAX&#xff1a;\u7ea6 9.22 \u00d7 10\u00b9\u2078\u3002<\/li>\n<\/ul>\n<p>INT32_MAX\u662f32\u4f4d&#xff0c;\u6807\u51c6\u6700\u5927\u503c\u3002 INT64_MAX\u662f64\u4f4d\u4e0b&#xff0c;\u6807\u51c6\u6700\u5927\u503c\u3002 0x3f3f3f3f3f3f3f3f&#xff0c;\u5e38\u5e38\u88ab\u5f52\u7eb3\u4e8e\u201c\u4f2a\u6700\u5927\u503c\u201d&#xff0c;\u5b83\u5373\u8d77\u5230\u6700\u5927\u503c\u7684\u4f5c\u7528&#xff0c;\u53c8\u80fd\u9002\u5f53\u7684\u76f8\u52a0\u3002\u5728\u56fe\u3001\u6811\u4e2d&#xff0c;\u5e38\u88ab\u8d4b\u4e88\u6743\u503c&#xff0c;\u8868\u793a\u4e0d\u53ef\u62b5\u8fbe\u7684\u70b9\u3002<\/p>\n<\/p>\n<h4><span style=\"color:#ad720d\">\u4e94\u3001\u5e7f\u641c(BFS)\u4e0e\u6df1\u641c(DFS)<\/span><\/h4>\n<h5>\u5e7f\u641c&#xff1a;<\/h5>\n<p>&#xff08;\u961f\u5217&#xff09;<\/p>\n<ul>\n<li>\u6700\u77ed\u8def\u5f84\u95ee\u9898&#xff0c;\u5e38\u7528\u4e8e\u5224\u65ad\u6700\u77ed\u8def\u5f84\u95ee\u9898\u3002<\/li>\n<li>\u56fe\u6216\u6811\u7684\u5c42\u5e8f\u904d\u5386\u95ee\u9898\u3002<\/li>\n<li>\u5224\u65ad\u8fde\u901a\u6027\u3002<\/li>\n<\/ul>\n<h5>\u6df1\u641c&#xff1a;<\/h5>\n<p>&#xff08;\u9012\u5f52\u3001\u6808&#xff09;<\/p>\n<ul>\n<li>\u8def\u5f84\u95ee\u9898&#xff0c;\u5bfb\u627e\u67d0\u4e00\u4e2a\u70b9\u5230\u53e6\u4e00\u4e2a\u70b9\u7684\u8def\u5f84&#xff0c;\u53ef\u80fd\u4e0d\u662f\u6700\u77ed\u8def\u5f84\u3002<\/li>\n<li>\u56de\u6eaf\u95ee\u9898&#xff0c;\u53ef\u7528\u4e8e\u67d0\u4e9b\u9700\u8981\u8bd5\u9519\u7684\u7b97\u6cd5&#xff08;\u89e3\u6570\u72ec\u3001\u516b\u7687\u540e&#xff09;<\/li>\n<li>\u6c42\u89e3\u7ec4\u5408\u95ee\u9898&#xff08;\u5168\u6392\u5217\u3001\u7ec4\u5408\u7b49\u95ee\u9898&#xff09;DFS\u53ef\u4ee5\u904d\u5386\u6240\u6709\u6709\u89e3\u7a7a\u95f4\u3002<\/li>\n<li>\u62d3\u6251\u6392\u5e8f&#xff0c;\u6682\u65f6\u8fd8\u4e0d\u719f\u6089<\/li>\n<\/ul>\n<h4><span style=\"color:#ad720d\">\u516d\u3001vector\u7684\u6bd4\u8f83\u65b9\u6848-map<\/span><\/h4>\n<p>\u5728C&#043;&#043;\u4e2d&#xff0c;\u4e24\u4e2avector\u6bd4\u8f83&#xff0c;\u662f\u901a\u8fc7operate&#061;&#061;&#xff0c;\u8fdb\u884c\u6bd4\u8f83\u7684\u3002<\/p>\n<p>\u5148\u6bd4\u8f83\u6570\u7ec4\u5927\u5c0f&#xff0c;\u5728\u4f9d\u6b21\u3001\u9010\u4e2a\u6bd4\u8f83\u5177\u4f53\u5185\u5bb9\u3002<\/p>\n<h5>map\u53ef\u4ee5\u4ee5vector\u4e3a\u952e<\/h5>\n<p>std::map \u57fa\u4e8e\u7ea2\u9ed1\u6811&#xff08;\u4e00\u79cd\u81ea\u5e73\u8861\u7684\u4e8c\u53c9\u641c\u7d22\u6811&#xff09;\u3002\u4f1a\u901a\u8fc7\u6392\u5e8f\u786e\u5b9a\u4f4d\u7f6e\u3002&#xff08;operate&lt;&#xff09;<\/p>\n<p>\u4e14vector\u5df2\u7ecf\u91cd\u8f7d\u8fc7(operate &lt;) \u4e86&#xff0c;\u6bd4\u8f83\u65f6&#xff0c;\u81ea\u52a8\u6309\u7167\u5b57\u5178\u5e8f\u6bd4\u8f83\u3002<\/p>\n<h5>unordered_map\u4e0d\u53ef\u4ee5\u4ee5vector\u4e3a\u952e<\/h5>\n<p>\u952e\u7684\u8981\u6c42\u662f<\/p>\n<p>1\u3001\u80fd\u6ee1\u8db3 \u54c8\u5e0c\u51fd\u6570 \u8f6c\u5316\u4e3a \u54c8\u5e0c\u503c\u3002<\/p>\n<p>2\u3001\u80fd\u901a\u8fc7operate&#061;&#061; \u8fdb\u884c\u6bd4\u8f83<\/p>\n<p>\u867d\u7136vector\u4e2d\u5b9a\u4e49\u4e86operate&#061;&#061;&#xff0c;\u4f46\u662f\u6ca1\u6709\u5b9a\u4e49&#xff0c;\u54c8\u5e0c\u51fd\u6570\u3002<\/p>\n<p>&#xff08;\u603b\u7ed3&#xff1a;map\u90fd\u5177\u5907&#xff0c;unordered_map\u4e0d\u80fd\u5c06vector\u8f6c\u5316\u4e3a\u54c8\u5e0c\u51fd\u6570&#xff09;<\/p>\n<hr \/>\n<p>\u501f\u9274\u89c6\u9891\u3001\u535a\u5ba2&#xff1a;<\/p>\n<p>1\u3001[\u7b97\u6cd5]\u8f7b\u677e\u638c\u63e1tarjan\u5f3a\u8fde\u901a\u5206\u91cf\u00a0&#8211; \u56fe<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e235\u6b21\uff0c\u6536\u85cf421\u6b21\u3002\u8bb0\u5f55\u5237\u9898\u7684\u8fc7\u7a0b\u3001\u611f\u609f\u3001\u9898\u89e3\u3002\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u5e0c\u671b\u80fd\u5e2e\u5230\uff0c\u90a3\u4e9b\u4e0e\u6211\u4e00\u540c\u524d\u884c\u7684\uff0c\u6765\u81ea\u8fdc\u65b9\u7684\u670b\u53cb\ud83d\ude09_2023\u5e74\u84dd\u6865\u676f\u771f\u9898c\u8bed\u8a00b\u7ec4<\/p>\n","protected":false},"author":2,"featured_media":12768,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[55,174,99,427,729],"topic":[],"class_list":{"0":"post-12779","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","6":"hentry","7":"category-server","8":"tag-c","10":"tag-java","11":"tag-427","12":"tag-729"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/12779.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e235\u6b21\uff0c\u6536\u85cf421\u6b21\u3002\u8bb0\u5f55\u5237\u9898\u7684\u8fc7\u7a0b\u3001\u611f\u609f\u3001\u9898\u89e3\u3002\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u5e0c\u671b\u80fd\u5e2e\u5230\uff0c\u90a3\u4e9b\u4e0e\u6211\u4e00\u540c\u524d\u884c\u7684\uff0c\u6765\u81ea\u8fdc\u65b9\u7684\u670b\u53cb\ud83d\ude09_2023\u5e74\u84dd\u6865\u676f\u771f\u9898c\u8bed\u8a00b\u7ec4\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/12779.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T11:54:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115450-68023d8af0fa6.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"19 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12779.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/12779.html\",\"name\":\"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T11:54:53+00:00\",\"dateModified\":\"2025-04-18T11:54:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/12779.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/12779.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/12779.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/12779.html","og_locale":"zh_CN","og_type":"article","og_title":"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.7w\u6b21\uff0c\u70b9\u8d5e235\u6b21\uff0c\u6536\u85cf421\u6b21\u3002\u8bb0\u5f55\u5237\u9898\u7684\u8fc7\u7a0b\u3001\u611f\u609f\u3001\u9898\u89e3\u3002\u200b\u200b\u200b\u200b\u200b\u200b\u200b\u5e0c\u671b\u80fd\u5e2e\u5230\uff0c\u90a3\u4e9b\u4e0e\u6211\u4e00\u540c\u524d\u884c\u7684\uff0c\u6765\u81ea\u8fdc\u65b9\u7684\u670b\u53cb\ud83d\ude09_2023\u5e74\u84dd\u6865\u676f\u771f\u9898c\u8bed\u8a00b\u7ec4","og_url":"https:\/\/www.wsisp.com\/helps\/12779.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T11:54:53+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418115450-68023d8af0fa6.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"19 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/12779.html","url":"https:\/\/www.wsisp.com\/helps\/12779.html","name":"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T11:54:53+00:00","dateModified":"2025-04-18T11:54:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/12779.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/12779.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/12779.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"2023\u7b2c\u5341\u56db\u5c4a\u84dd\u6865\u676f\u5927\u8d5b\u8f6f\u4ef6\u8d5b\u56fd\u8d5bC\/C++ \u5927\u5b66 B \u7ec4(\u771f\u9898&amp;\u9898\u89e3)\uff08C++\/Java\u9898\u89e3\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=12779"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/12779\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/12768"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=12779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=12779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=12779"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=12779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}