{"id":1589,"date":"2026-05-19T16:14:43","date_gmt":"2026-05-19T08:14:43","guid":{"rendered":"http:\/\/wordpress.fangt.online\/?p=1589"},"modified":"2026-05-19T16:14:43","modified_gmt":"2026-05-19T08:14:43","slug":"%e9%ab%98%e7%b2%be%e5%ba%a6%e9%99%a4%e6%b3%95%ef%bc%88%e9%9d%9e%e9%87%8d%e7%82%b9%ef%bc%89","status":"publish","type":"post","link":"http:\/\/wordpress.fangt.online\/index.php\/2026\/05\/19\/%e9%ab%98%e7%b2%be%e5%ba%a6%e9%99%a4%e6%b3%95%ef%bc%88%e9%9d%9e%e9%87%8d%e7%82%b9%ef%bc%89\/","title":{"rendered":"\u9ad8\u7cbe\u5ea6\u9664\u6cd5\uff08\u975e\u91cd\u70b9\uff09"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">\u7b97\u6cd5\u601d\u8def\uff08\u7ad6\u5f0f\u6a21\u62df\uff09<\/h3>\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;string>\n#include &lt;algorithm>\nusing namespace std;\n\n\/\/ \u6bd4\u8f83\u4e24\u4e2a\u6b63\u6574\u6570\u5b57\u7b26\u4e32\u7684\u5927\u5c0f\uff08\u5df2\u53bb\u9664\u524d\u5bfc\u96f6\uff09\nbool greaterOrEqual(const string&amp; a, const string&amp; b) {\n    if (a.size() != b.size()) return a.size() > b.size();\n    return a >= b;\n}\n\n\/\/ \u9ad8\u7cbe\u5ea6\u51cf\u6cd5\uff1aa - b\uff0c\u8981\u6c42 a >= b\uff0c\u8fd4\u56de\u7ed3\u679c\u5b57\u7b26\u4e32\nstring subString(const string&amp; a, const string&amp; b) {\n    string res;\n    int borrow = 0;\n    int i = a.size() - 1, j = b.size() - 1;\n    while (i >= 0 || j >= 0) {\n        int diff = (i >= 0 ? a&#91;i] - '0' : 0) - borrow;\n        if (j >= 0) diff -= (b&#91;j] - '0');\n        if (diff &lt; 0) {\n            diff += 10;\n            borrow = 1;\n        } else {\n            borrow = 0;\n        }\n        res.push_back(diff + '0');\n        i--; j--;\n    }\n    \/\/ \u53bb\u9664\u524d\u5bfc\u96f6\n    while (res.size() > 1 &amp;&amp; res.back() == '0') res.pop_back();\n    reverse(res.begin(), res.end());\n    return res;\n}\n\n\/\/ \u9ad8\u7cbe\u5ea6\u4e58\u6cd5\uff1a\u5b57\u7b26\u4e32 * \u4e00\u4f4d\u6574\u6570 (0-9)\nstring mulString(const string&amp; a, int d) {\n    if (d == 0) return \"0\";\n    string res;\n    int carry = 0;\n    for (int i = a.size() - 1; i >= 0; --i) {\n        int prod = (a&#91;i] - '0') * d + carry;\n        res.push_back(prod % 10 + '0');\n        carry = prod \/ 10;\n    }\n    while (carry) {\n        res.push_back(carry % 10 + '0');\n        carry \/= 10;\n    }\n    reverse(res.begin(), res.end());\n    return res;\n}\n\n\/\/ \u9ad8\u7cbe\u5ea6\u9664\u6cd5\uff1aa \/ b\uff0c\u8fd4\u56de\u5546\u548c\u4f59\u6570\uff08\u4f59\u6570\u901a\u8fc7\u5f15\u7528\u8fd4\u56de\uff09\nstring divBig(const string&amp; a, const string&amp; b, string&amp; remainder) {\n    if (b == \"0\") throw runtime_error(\"Division by zero\");\n    if (!greaterOrEqual(a, b)) {\n        remainder = a;\n        return \"0\";\n    }\n    string quotient;\n    remainder = \"\";   \/\/ \u5f53\u524d\u4f59\u6570\uff08\u521d\u59cb\u4e3a\u7a7a\uff09\n    \/\/ \u904d\u5386\u88ab\u9664\u6570\u7684\u6bcf\u4e00\u4f4d\n    for (char ch : a) {\n        remainder.push_back(ch);           \/\/ \u5c06\u4e0b\u4e00\u4f4d\u52a0\u5165\u4f59\u6570\u672b\u5c3e\n        \/\/ \u53bb\u9664\u4f59\u6570\u7684\u524d\u5bfc\u96f6\uff08\u4fdd\u7559\u4e00\u4e2a '0'\uff09\n        size_t pos = remainder.find_first_not_of('0');\n        if (pos != string::npos) remainder = remainder.substr(pos);\n        else remainder = \"0\";\n\n        \/\/ \u5728\u5f53\u524d\u4f59\u6570\u4e0b\u8bd5\u5546\uff080-9\uff09\n        int q = 0;\n        string product;\n        \/\/ \u5c1d\u8bd5\u4ece9\u52300\uff0c\u627e\u5230\u6700\u5927\u7684 q \u4f7f\u5f97 q*b &lt;= remainder\n        for (int d = 9; d >= 0; --d) {\n            product = mulString(b, d);\n            if (greaterOrEqual(remainder, product)) {\n                q = d;\n                break;\n            }\n        }\n        quotient.push_back(q + '0');\n        \/\/ \u51cf\u53bb product\n        remainder = subString(remainder, product);\n    }\n    \/\/ \u53bb\u9664\u5546\u7684\u524d\u5bfc\u96f6\n    size_t pos = quotient.find_first_not_of('0');\n    if (pos == string::npos) quotient = \"0\";\n    else quotient = quotient.substr(pos);\n    \/\/ \u4f59\u6570\u53ef\u80fd\u4e3a\u7a7a\uff0c\u5219\u7f6e \"0\"\n    if (remainder.empty()) remainder = \"0\";\n    return quotient;\n}\n\nint main() {\n    string a, b;\n    cin >> a >> b;\n    string rem;\n    string q = divBig(a, b, rem);\n    cout &lt;&lt; \"\u5546: \" &lt;&lt; q &lt;&lt; \"\\n\u4f59\u6570: \" &lt;&lt; rem &lt;&lt; endl;\n    return 0;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b97\u6cd5\u601d\u8def\uff08\u7ad6\u5f0f\u6a21\u62df\uff09 \u4ee3\u7801\u5b9e\u73b0<\/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-1589","post","type-post","status-publish","format-standard","hentry","category-zl"],"_links":{"self":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1589","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=1589"}],"version-history":[{"count":1,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1589\/revisions"}],"predecessor-version":[{"id":1590,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/posts\/1589\/revisions\/1590"}],"wp:attachment":[{"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/media?parent=1589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/categories?post=1589"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wordpress.fangt.online\/index.php\/wp-json\/wp\/v2\/tags?post=1589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}