{"id":1585,"date":"2026-05-19T15:58:32","date_gmt":"2026-05-19T07:58:32","guid":{"rendered":"http:\/\/wordpress.fangt.online\/?p=1585"},"modified":"2026-05-19T15:58:32","modified_gmt":"2026-05-19T07:58:32","slug":"%e9%ab%98%e7%b2%be%e5%ba%a6%e4%b9%98%e6%b3%95","status":"publish","type":"post","link":"http:\/\/wordpress.fangt.online\/index.php\/2026\/05\/19\/%e9%ab%98%e7%b2%be%e5%ba%a6%e4%b9%98%e6%b3%95\/","title":{"rendered":"\u9ad8\u7cbe\u5ea6\u4e58\u6cd5"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u57fa\u672c\u539f\u7406<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u9ad8\u7cbe\u5ea6\u4e58\u9ad8\u7cbe\u5ea6\uff0c\u4ecd\u7136\u6a21\u62df\u624b\u5de5\u7ad6\u5f0f\u4e58\u6cd5\u7684\u8fc7\u7a0b\u3002\u4f8b\u5982\u8ba1\u7b97&nbsp;<code>123 \u00d7 45<\/code>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>      1 2 3\n\u00d7       4 5\n-----------\n      6 1 5   (123 \u00d7 5)\n+   4 9 2     (123 \u00d7 4\uff0c\u5411\u5de6\u504f\u79fb\u4e00\u4f4d)\n-----------\n    5 5 3 5<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8ba1\u7b97\u673a\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u6570\u7ec4\uff08\u5c0f\u7aef\u5e8f\uff09\u5b58\u50a8\u6bcf\u4e00\u4f4d\uff0c\u7136\u540e\uff1a<\/p>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u7528\u4e00\u4e2a\u53cc\u91cd\u5faa\u73af\uff0c\u5c06\u7b2c\u4e00\u4e2a\u6570\u7684\u6bcf\u4e00\u4f4d\u4e58\u4ee5\u7b2c\u4e8c\u4e2a\u6570\u7684\u6bcf\u4e00\u4f4d\u3002<\/li>\n\n\n\n<li>\u4e58\u79ef\u7684\u4e2a\u4f4d\u653e\u5728\u7ed3\u679c\u6570\u7ec4\u7684\u5bf9\u5e94\u4f4d\u7f6e\uff08\u4e0b\u6807\u00a0<code>i+j<\/code>\uff09\uff0c\u5341\u4f4d\u53ca\u4ee5\u4e0a\u4f5c\u4e3a\u8fdb\u4f4d\u7d2f\u52a0\u5230\u66f4\u9ad8\u4f4d\u3002<\/li>\n\n\n\n<li>\u6700\u540e\u5904\u7406\u6240\u6709\u8fdb\u4f4d\uff0c\u5e76\u53bb\u9664\u524d\u5bfc\u96f6\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u7b97\u6cd5\u6b65\u9aa4<\/h3>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u521d\u59cb\u5316\u7ed3\u679c\u6570\u7ec4\u00a0<code>c<\/code>\uff0c\u957f\u5ea6\u81f3\u5c11\u4e3a\u00a0<code>len(a)+len(b)<\/code>\uff0c\u6240\u6709\u5143\u7d20\u4e3a 0\u3002<\/li>\n\n\n\n<li>\u904d\u5386\u00a0<code>i<\/code>\u00a0\u4ece 0 \u5230\u00a0<code>len(a)-1<\/code>\uff1a\n<ul class=\"wp-block-list\">\n<li>\u521d\u59cb\u5316\u8fdb\u4f4d\u00a0<code>carry = 0<\/code>\u3002<\/li>\n\n\n\n<li>\u904d\u5386\u00a0<code>j<\/code>\u00a0\u4ece 0 \u5230\u00a0<code>len(b)-1<\/code>\uff1a\n<ul class=\"wp-block-list\">\n<li><code>temp = c[i+j] + a[i] * b[j] + carry<\/code><\/li>\n\n\n\n<li><code>c[i+j] = temp % 10<\/code><\/li>\n\n\n\n<li><code>carry = temp \/ 10<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5982\u679c\u00a0<code>carry > 0<\/code>\uff0c\u7ee7\u7eed\u5411\u9ad8\u4f4d\u4f20\u9012\uff1a<code>c[i+len(b)] += carry<\/code>\uff0c\u4f46\u8fd9\u91cc\u9700\u8981\u5faa\u73af\u5904\u7406\u8fdb\u4f4d\uff08\u56e0\u4e3a\u4e00\u6b21\u8fdb\u4f4d\u53ef\u80fd\u4f20\u64ad\u591a\u4f4d\uff09\u3002\u7b80\u4fbf\u505a\u6cd5\u662f\u5728\u5185\u5c42\u5faa\u73af\u7ed3\u675f\u540e\uff0c\u7528\u00a0<code>while<\/code>\u00a0\u5904\u7406\u5269\u4f59\u8fdb\u4f4d\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u53bb\u9664\u7ed3\u679c\u6570\u7ec4\u672b\u5c3e\uff08\u9ad8\u4f4d\uff09\u7684\u591a\u4f59\u96f6\uff0c\u4f46\u81f3\u5c11\u4fdd\u7559\u4e00\u4f4d\uff08\u7ed3\u679c\u4e3a 0 \u65f6\u4fdd\u7559\u4e00\u4e2a 0\uff09\u3002<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">\u4ee3\u7801\u5b9e\u73b0<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream>\n#include &lt;vector>\n#include &lt;string>\n#include &lt;algorithm>\n\nusing namespace std;\n\n\/\/ \u5b57\u7b26\u4e32\u8f6c\u5c0f\u7aef\u5e8f vector\nvector&lt;int> strToVec(const string&amp; s) {\n    vector&lt;int> v;\n    for (int i = s.size() - 1; i >= 0; --i)\n        v.push_back(s&#91;i] - '0');\n    return v;\n}\n\n\/\/ \u53bb\u9664\u524d\u5bfc\u96f6\nvoid trim(vector&lt;int>&amp; v) {\n    while (v.size() > 1 &amp;&amp; v.back() == 0)\n        v.pop_back();\n}\n\n\/\/ \u9ad8\u7cbe\u5ea6 \u00d7 \u9ad8\u7cbe\u5ea6\nvector&lt;int> mulBig(const vector&lt;int>&amp; a, const vector&lt;int>&amp; b) {\n    vector&lt;int> c(a.size() + b.size(), 0); \/\/ \u7ed3\u679c\u6700\u591a\u6709 len(a)+len(b) \u4f4d\n    for (size_t i = 0; i &lt; a.size(); ++i) {\n        int carry = 0;\n        for (size_t j = 0; j &lt; b.size(); ++j) {\n            int temp = c&#91;i + j] + a&#91;i] * b&#91;j] + carry;\n            c&#91;i + j] = temp % 10;\n            carry = temp \/ 10;\n        }\n        \/\/ \u5904\u7406\u5269\u4f59\u8fdb\u4f4d\n        size_t idx = i + b.size();\n        while (carry) {\n            int temp = c&#91;idx] + carry;\n            c&#91;idx] = temp % 10;\n            carry = temp \/ 10;\n            ++idx;\n        }\n    }\n    trim(c);\n    return c;\n}\n\n\/\/ \u8f93\u51fa\u5927\u6570\nvoid printVec(const vector&lt;int>&amp; v) {\n    for (int i = v.size() - 1; i >= 0; --i)\n        cout &lt;&lt; v&#91;i];\n    cout &lt;&lt; endl;\n}\n\nint main() {\n    string s1, s2;\n    cin >> s1 >> s2;\n    vector&lt;int> a = strToVec(s1);\n    vector&lt;int> b = strToVec(s2);\n    vector&lt;int> result = mulBig(a, b);\n    printVec(result);\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u672c\u539f\u7406 \u9ad8\u7cbe\u5ea6\u4e58\u9ad8\u7cbe\u5ea6\uff0c\u4ecd\u7136\u6a21\u62df\u624b\u5de5\u7ad6\u5f0f\u4e58\u6cd5\u7684\u8fc7\u7a0b\u3002\u4f8b\u5982\u8ba1\u7b97&nbsp;123 \u00d7 45\uff1a \u5728\u8ba1\u7b97\u673a\u4e2d\uff0c\u6211\u4eec [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-1585","post","type-post","status-publish","format-standard","hentry","category-zl"],"_links":{"self":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/comments?post=1585"}],"version-history":[{"count":1,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1585\/revisions"}],"predecessor-version":[{"id":1586,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1585\/revisions\/1586"}],"wp:attachment":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/media?parent=1585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/categories?post=1585"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/tags?post=1585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}