{"id":117,"date":"2023-04-03T16:27:25","date_gmt":"2023-04-03T08:27:25","guid":{"rendered":"https:\/\/solost.cn\/?p=117"},"modified":"2023-04-03T16:27:25","modified_gmt":"2023-04-03T08:27:25","slug":"224","status":"publish","type":"post","link":"https:\/\/solost.cn\/?p=117","title":{"rendered":"\u9ad8\u7cbe\u5ea6\u51cf\u6cd5"},"content":{"rendered":"<pre><code class=\"lang-cpp\">#include &lt;iostream&gt;\n#include &lt;vector&gt;\n\nusing namespace std;\n\nbool cmp(vector&lt;int&gt; &amp;A, vector&lt;int&gt; &amp;B)\n{\n    if (A.size() != B.size()) return A.size() &gt; B.size();\n\n    for (int i = A.size() - 1; i &gt;= 0; i -- )\n        if (A[i] != B[i])\n            return A[i] &gt; B[i];\n\n    return true;\n}\n\nvector&lt;int&gt; sub(vector&lt;int&gt; &amp;A, vector&lt;int&gt; &amp;B)\n{\n    vector&lt;int&gt; C;\n    for (int i = 0, t = 0; i &lt; A.size(); i ++ )\n    {\n        t = A[i] - t;\n        if (i &lt; B.size()) t -= B[i];\n        C.push_back((t + 10) % 10);\n        if (t &lt; 0) t = 1;\n        else t = 0;\n    }\n\n    while (C.size() &gt; 1 &amp;&amp; C.back() == 0) C.pop_back();\n    return C;\n}\n\nint main()\n{\n    string a, b;\n    vector&lt;int&gt; A, B;\n    cin &gt;&gt; a &gt;&gt; b;\n    for (int i = a.size() - 1; i &gt;= 0; i -- ) A.push_back(a[i] - &#039;0&#039;);\n    for (int i = b.size() - 1; i &gt;= 0; i -- ) B.push_back(b[i] - &#039;0&#039;);\n\n    vector&lt;int&gt; C;\n\n    if (cmp(A, B)) C = sub(A, B);\n    else C = sub(B, A), cout &lt;&lt; &#039;-&#039;;\n\n    for (int i = C.size() - 1; i &gt;= 0; i -- ) cout &lt;&lt; C[i];\n    cout &lt;&lt; endl;\n\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#include &lt;iostream&gt; #include &lt;vector&gt; using namespace std; bool cmp(vector&lt;int&gt; &amp;A, vector&lt;int&gt; &amp;B) { if (A.size() != B.size()) return A.size() &gt; B.size(); for (int i = A.size() - 1; i &gt;= 0; i -- ) if (A[i] != B[i]) return A[i] &gt; B[i]; return true; } vector&lt;int&gt; sub(vector&lt;int&gt; &amp;A, vector&lt;int&gt; &amp;B) { vector&lt;int&gt; C; for (int [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[29],"class_list":["post-117","post","type-post","status-publish","format-standard","hentry","category-acm","tag-29"],"_links":{"self":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/117","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=117"}],"version-history":[{"count":0,"href":"https:\/\/solost.cn\/index.php?rest_route=\/wp\/v2\/posts\/117\/revisions"}],"wp:attachment":[{"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=117"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=117"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/solost.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=117"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}