{"id":480,"date":"2021-07-03T10:43:20","date_gmt":"2021-07-03T02:43:20","guid":{"rendered":"https:\/\/swordofmorning.com\/?p=480"},"modified":"2025-10-09T13:56:04","modified_gmt":"2025-10-09T05:56:04","slug":"the-number-of-cultural-strokes-in-arabic-numerals","status":"publish","type":"post","link":"https:\/\/swordofmorning.com\/index.php\/2021\/07\/03\/the-number-of-cultural-strokes-in-arabic-numerals\/","title":{"rendered":"\u963f\u62c9\u4f2f\u6570\u5b57\u4e2d\u6587\u5316\u7684\u7b14\u753b\u6570"},"content":{"rendered":"<h2>\u7b80\u4ecb<\/h2>\n<p>&emsp;&emsp;\u8fd9\u91cc\u8981\u6c42\u628a\u963f\u62c9\u4f2f\u6570\u5b57\u4e2d\u6587\u5316\uff0c\u7136\u540e\u8f93\u51fa\u5176\u7b14\u5212\u6570\uff1a<br \/>\n&emsp;&emsp;\u4f8b\u5982\uff1a14562 -&gt; \u4e00\u4e07\u56db\u5343\u4e94\u767e\u516d\u5341\u4e8c\uff0c\u537330\u5212<\/p>\n<h2>\u601d\u8def<\/h2>\n<p>&emsp;&emsp;\u8fd9\u91cc\u63d0\u4f9b\u4e2a\u60f3\u6cd5\uff1a\u6570\u7ea7\u548c\u6570\u4f4d<\/p>\n<ol>\n<li>&emsp;&emsp;\u4e2d\u6587\u8ba1\u6570\u65f6\u4f1a\u7528\u52304\u4e2a\u6570\u4f4d\uff1a\u4e2a\u3001\u5341\u3001\u767e\u3001\u5343<\/li>\n<li>&emsp;&emsp;\u4f1a\u5e38\u7528\u5230\u4ee5\u4e0b\u6570\u7ea7\uff1a\u4e2a\u3001\u4e07\u3001\u4ebf<\/li>\n<\/ol>\n<p>&emsp;&emsp;\u90a3\u4e48\uff0c\u6211\u4eec\u4ee5\u4e0d\u8d85\u8fc7\u4e07\u4ebf\u6765\u770b\uff1a<\/p>\n<ol>\n<li>&emsp;&emsp;\u5c06\u6570\u5b57\u4ee54\u4e2a\u4e00\u7ec4\u62c6\u5206\u4e3an\u7ec4\uff0c\u5bf9\u5176\u5012\u53d9\u6dfb\u52a0\u6570\u7ea7\u201c\u4e2a\u201d\u201c\u4e07\u201d\u201c\u4ebf\u201d<\/li>\n<li>&emsp;&emsp;\u5c06\u6bcf\u4e00\u7ec4\u6570\u8fdb\u884c\u5012\u53d9\u904d\u5386\uff0c\u9047\u5230\u975e0\u6570\u76f4\u63a5\u66ff\u6362\uff0c\u9047\u52300\u66ff\u6362\u4e3a\u96f6\uff0c\u7136\u540e\u5bfb\u627e\u4e0b\u4e00\u4e2a\u975e\u96f6\u7684\u6570\u3002<\/li>\n<li>&emsp;&emsp;\u540c\u6837\uff0c\u5982\u679c\u57282\u4e2d\u67e5\u627e\u975e0\u6570\u8fd4\u56denpos\uff0c\u5219\u76f4\u63a5\u8df3\u8fc7\u672c\u7ec4\u6570\u636e\u3002<\/li>\n<\/ol>\n<h2>\u4ee3\u7801<\/h2>\n<pre><code>#include &lt;iostream&gt;\n#include &lt;algorithm&gt;\n#include &lt;string&gt;\n#include &lt;map&gt;\n\nstd::map&lt;char, int&gt; Numbers;    \/\/\u6570\nstd::map&lt;int, int&gt; Digit;       \/\/\u6570\u4f4d\uff08\u4e2a\u5341\u767e\u5343\uff09\nstd::map&lt;int, int&gt; Level;       \/\/\u6570\u7ea7\uff08\u4ebf\u3001\u4e07\u3001\u4e2a\uff09\n\nvoid init();\nint Cal(const std::string&amp; str_p);\n\nint main()\n{\n    init();\n    \/\/\u521d\u59cb\u5316\n\n    std::string str;\n    std::cin &gt;&gt; str;\n\n    int ans = Cal(str);\n    if (str.length() == 2 &amp;&amp; str.front() == &#039;1&#039;)\n    {\n        ans -= 1;\n    }\n\n    std::cout &lt;&lt; ans &lt;&lt; std::endl;\n\n    return 0;\n}\n\nvoid init()\n{\n    \/*---Numbers init---*\/\n    Numbers[&#039;0&#039;] = 13;  \/\/\u96f6\n    Numbers[&#039;1&#039;] = 1;   \/\/\u4e00\n    Numbers[&#039;2&#039;] = 2;   \/\/\u4e8c\n    Numbers[&#039;3&#039;] = 3;   \/\/\u4e09\n    Numbers[&#039;4&#039;] = 5;   \/\/\u56db\n\n    Numbers[&#039;5&#039;] = 4;   \/\/\u4e94_\n    Numbers[&#039;6&#039;] = 4;   \/\/\u516d\n    Numbers[&#039;7&#039;] = 2;   \/\/\u4e03\n    Numbers[&#039;8&#039;] = 2;   \/\/\u516b\n    Numbers[&#039;9&#039;] = 2;   \/\/\u4e5d\n    \/*---end---*\/\n\n    \/*---Digit init---*\/\n    Digit[0] = 0;       \/\/\u4e2a\n    Digit[1] = 2;       \/\/\u5341\n    Digit[2] = 6;       \/\/\u767e\n    Digit[3] = 3;       \/\/\u5343\n    \/*---end---*\/\n\n    \/*---Level init---*\/\n    Level[0] = 0;               \/\/\u4e2a\n    Level[1] = 3 + Level[0];    \/\/\u4e07\u4e2a\n    Level[2] = 2 + Level[1];    \/\/\u4ebf\u4e07\u4e2a\n    \/\/\u8fd9\u91cceg\uff1a333,888,888\uff1a\u4e09\u201c\u4ebf\u201d\u516b\u5343\u516b\u767e\u516b\u5341\u516b\u201c\u4e07\u201d\u516b\u767e\u516b\u5341\u516b\n    \/*---end---*\/\n}\n\nint Cal(const std::string&amp; str_p)\n{\n    int re_level = Level[(str_p.length() - 1) \/ 4];\n    \/\/***\u6c42\u2460\u6570\u7ea7\u7684\u7b14\u753b***\n\n    std::string str_f(str_p);\n    \/\/\u6784\u9020str_f\u4ee5\u586b\u5145\u4e3ax\u4ebfxxxx\u4e07xxxx\n    while (str_f.length() &lt; 9)\n    {\n        str_f.insert(str_f.begin(), { &#039;0&#039; });\n    }\n\n    std::reverse(str_f.begin(), str_f.end());\n    \/\/\u7ffb\u8f6c\n\n    int re_digit(0);\n    \/\/***\u6570\u4f4d\u7b14\u753b***\n\n    str_f.back() == &#039;0&#039; ? re_digit += 0 : re_digit += Numbers[str_f.back()];\n    \/\/\u4ebf\u7ea7\n\n    std::string str_dig = str_f.substr(0, 4);\n    std::string str_tTh = str_f.substr(4, 4);\n    \/\/\u4e2a\u7ea7 \u548c \u4e07\u7ea7\u7684\u4e24\u4e2a\u5b50\u5b57\u7b26\u4e32\n\n    if (str_dig.find_first_not_of(&#039;0&#039;) != std::string::npos)\n    {\n        for (std::string::const_iterator it = str_dig.begin() + str_dig.find_first_not_of(&#039;0&#039;);\n            it != str_dig.end(); ++it)\n        {\n            re_digit += Numbers[*it];\n            \/\/\u2461\u6570\n            if (*it == &#039;0&#039;)\n            {\n                int a = it - str_dig.begin();\n                \/\/\u2462\u6570\u4f4d\n                if (str_dig.find_first_not_of(&#039;0&#039;, it - str_dig.begin()) == std::string::npos)\n                {\n                    re_digit -= Numbers[*it];\n                    break;\n                }\n                else if (str_dig.find_first_not_of(&#039;0&#039;, it - str_dig.begin()) != std::string::npos)\n                {\n                    it += str_dig.find_first_not_of(&#039;0&#039;, it - str_dig.begin());\n                    continue;\n                }\n            }\n            else if (*it != &#039;0&#039;)\n            {\n                re_digit += Digit[it - str_dig.begin()];\n            }\n        }\n    }\n\n    if (str_tTh.find_first_not_of(&#039;0&#039;) != std::string::npos)\n    {\n        for (std::string::const_iterator it = str_tTh.begin() + str_tTh.find_first_not_of(&#039;0&#039;);\n            it != str_tTh.end(); ++it)\n        {\n            re_digit += Numbers[*it];\n            \/\/\u2461\u6570\n            if (*it == &#039;0&#039;)\n            {\n                int a = it - str_tTh.begin();\n                \/\/\u2462\u6570\u4f4d\n                if (str_tTh.find_first_not_of(&#039;0&#039;, it - str_tTh.begin()) == std::string::npos)\n                {\n                    re_digit -= Numbers[*it];\n                    break;\n                }\n                else if (str_tTh.find_first_not_of(&#039;0&#039;, it - str_tTh.begin()) != std::string::npos)\n                {\n                    it += str_tTh.find_first_not_of(&#039;0&#039;, it - str_tTh.begin());\n                    continue;\n                }\n            }\n            else if (*it != &#039;0&#039;)\n            {\n                re_digit += Digit[it - str_tTh.begin()];\n            }\n        }\n    }\n\n    return re_digit + re_level;\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb &emsp;&emsp;\u8fd9\u91cc\u8981\u6c42\u628a\u963f\u62c9\u4f2f\u6570\u5b57\u4e2d\u6587\u5316\uff0c\u7136\u540e\u8f93\u51fa\u5176\u7b14\u5212\u6570\uff1a &emsp;&emsp;\u4f8b\u5982\uff1a14562 -&gt; &#8230;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/480"}],"collection":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/comments?post=480"}],"version-history":[{"count":2,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/480\/revisions"}],"predecessor-version":[{"id":490,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/posts\/480\/revisions\/490"}],"wp:attachment":[{"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/media?parent=480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/categories?post=480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/swordofmorning.com\/index.php\/wp-json\/wp\/v2\/tags?post=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}