{"id":646,"date":"2020-03-05T10:08:51","date_gmt":"2020-03-05T02:08:51","guid":{"rendered":"http:\/\/kylelv.com\/?p=646"},"modified":"2020-03-10T00:01:36","modified_gmt":"2020-03-09T16:01:36","slug":"%e5%a4%a7%e6%95%b4%e6%95%b0-%e8%bf%90%e7%ae%97%e7%ac%a6%e9%87%8d%e8%bd%bd","status":"publish","type":"post","link":"https:\/\/blog.kylelv.com\/?p=646","title":{"rendered":"\u5927\u6574\u6570 &#8212; \u8fd0\u7b97\u7b26\u91cd\u8f7d"},"content":{"rendered":"\n<h2 class=\"has-text-align-center wp-block-heading\">E:\u522b\u53eb\uff0c\u8fd9\u4e2a\u5927\u6574\u6570\u5df2\u7ecf\u5f88\u7b80\u5316\u4e86!<\/h2>\n\n\n\n<p class=\"has-text-align-center\">\u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB<\/p>\n\n\n\n<p class=\"has-text-align-left\">\u63cf\u8ff0<\/p>\n\n\n\n<p>\u7a0b\u5e8f\u586b\u7a7a\uff0c\u8f93\u51fa\u6307\u5b9a\u7ed3\u679c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include &lt;iostream&gt; \n#include &lt;cstring&gt; \n#include &lt;cstdlib&gt; \n#include &lt;cstdio&gt; \nusing namespace std;\nconst int MAX = 110; \nclass CHugeInt {<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ \u5728\u6b64\u5904\u8865\u5145\u4f60\u7684\u4ee3\u7801<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">};\nint  main() \n{ \n\tchar s[210];\n\tint n;\n\n\twhile (cin &gt;&gt; s &gt;&gt; n) {\n\t\tCHugeInt a(s);\n\t\tCHugeInt b(n);\n\n\t\tcout &lt;&lt; a + b &lt;&lt; endl;\n\t\tcout &lt;&lt; n + a &lt;&lt; endl;\n\t\tcout &lt;&lt; a + n &lt;&lt; endl;\n\t\tb += n;\n\t\tcout  &lt;&lt; ++ b &lt;&lt; endl;\n\t\tcout &lt;&lt; b++ &lt;&lt; endl;\n\t\tcout &lt;&lt; b &lt;&lt; endl;\n\t}\n\treturn 0;\n}<\/pre>\n\n\n\n<p>\u8f93\u5165\u591a\u7ec4\u6570\u636e\uff0c\u6bcf\u7ec4\u6570\u636e\u662f\u4e24\u4e2a\u975e\u8d1f\u6574\u6570s\u548c n\u3002s\u6700\u591a\u53ef\u80fd200\u4f4d\uff0c n\u7528int\u80fd\u8868\u793a\u8f93\u51fa\u5bf9\u6bcf\u7ec4\u6570\u636e\uff0c\u8f93\u51fa6\u884c\uff0c\u5185\u5bb9\u5206\u522b\u662f\uff1a<\/p>\n\n\n\n<p>\u6837\u4f8b\u8f93\u5165<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">99999999999999999999999999888888888888888812345678901234567789 12\n6 6\n<\/pre>\n\n\n\n<p>\u6837\u4f8b\u8f93\u51fa<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">99999999999999999999999999888888888888888812345678901234567801\n99999999999999999999999999888888888888888812345678901234567801\n99999999999999999999999999888888888888888812345678901234567801\n25\n25\n26\n12\n12\n12\n13\n13\n14\n<\/pre>\n\n\n\n<p>\u6765\u6e90Guo Wei<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream> \n#include &lt;cstring> \n#include &lt;cstdlib> \n#include &lt;cstdio> \nusing namespace std;\nconst int MAX = 110; \nclass CHugeInt {\n\tchar s[210];\n\tint len;\n\tpublic:\n\tCHugeInt(const char *a){\n\t\tmemset(s,0,sizeof(s));\n\t\tlen=strlen(a);\n\t\tfor(int i=len-1;~i;--i)\n\t\t\ts[i]=a[len-i-1]-'0';\n\t}\n\tCHugeInt(int a){\n\t\tmemset(s,0,sizeof(s));\n\t\tlen=0;\n\t\twhile(a){\n\t\t\ts[len++]=a%10;\n\t\t\ta\/=10;\n\t\t}\n\t}\n\tfriend ostream &amp; operator &lt;&lt;(ostream &amp;o,const CHugeInt &amp;a){\n\t\tfor(int i=a.len-1;~i;--i)\n\t\t\tputchar(a.s[i]+'0');\n\t\treturn o;\n\t}\n\tCHugeInt operator +(const CHugeInt &amp;a){\n\t\tCHugeInt tp(0);\n\t\ttp.len=max(len,a.len);\n\t\tfor(int i=0;i&lt;tp.len;++i){\n\t\t\ttp.s[i]+=s[i]+a.s[i];\n\t\t\tif(tp.s[i]>9) tp.s[i]-=10,++tp.s[i+1];\n\t\t}\n\t\tif(tp.s[tp.len]) ++tp.len;\n\t\treturn tp;\n\t}\n\tfriend CHugeInt operator +(const int &amp;z,const CHugeInt &amp;a){\n\t\tCHugeInt tp(0),b(z);\n\t\ttp.len=max(b.len,a.len);\n\t\tfor(int i=0;i&lt;tp.len;++i){\n\t\t\ttp.s[i]+=b.s[i]+a.s[i];\n\t\t\tif(tp.s[i]>9) tp.s[i]-=10,++tp.s[i+1];\n\t\t}\n\t\tif(tp.s[tp.len]) ++tp.len;\n\t\treturn tp;\n\t}\n\tCHugeInt &amp; operator +=(const int &amp;z){\n\t\tCHugeInt b(z);\n\t\tlen=max(len,b.len);\n\t\tfor(int i=0;i&lt;len;++i){\n\t\t\ts[i]+=b.s[i];\n\t\t\tif(s[i]>9) s[i]-=10,++s[i+1];\n\t\t}\n\t\tif(s[len]) ++len;\n\t\treturn *this;\n\t}\n\tCHugeInt &amp; operator ++(){\n\t\tint i=0;++s[0];\n\t\twhile(s[i]>9) s[i]-=10,++s[++i];\n\t\tlen=max(len,i+1);\n\t\treturn *this;\n\t}\n\tCHugeInt operator ++(int){\n\t\tCHugeInt tp(*this);\n\t\tint i=0;++s[0];\n\t\twhile(s[i]>9) s[i]-=10,++s[++i];\n\t\tlen=max(len,i+1);\n\t\treturn tp;\n\t}\n\/\/ \u5728\u6b64\u5904\u8865\u5145\u4f60\u7684\u4ee3\u7801\n};\nint  main() \n{ \n\tchar s[210];\n\tint n;\n\n\twhile (cin >> s >> n) {\n\t\tCHugeInt a(s);\n\t\tCHugeInt b(n);\n\n\t\tcout &lt;&lt; a + b &lt;&lt; endl;\n\t\tcout &lt;&lt; n + a &lt;&lt; endl;\n\t\tcout &lt;&lt; a + n &lt;&lt; endl;\n\t\tb += n;\n\t\tcout  &lt;&lt; ++ b &lt;&lt; endl;\n\t\tcout &lt;&lt; b++ &lt;&lt; endl;\n\t\tcout &lt;&lt; b &lt;&lt; endl;\n\t}\n\treturn 0;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>E:\u522b\u53eb\uff0c\u8fd9\u4e2a\u5927\u6574\u6570\u5df2\u7ecf\u5f88\u7b80\u5316\u4e86! \u603b\u65f6\u95f4\u9650\u5236:\u00a01000ms\u00a0\u5185\u5b58\u9650\u5236:\u00a065536kB \u63cf\u8ff0 \u7a0b\u5e8f\u586b\u7a7a\uff0c\u8f93 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[70],"tags":[],"class_list":["post-646","post","type-post","status-publish","format-standard","hentry","category-70"],"_links":{"self":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=646"}],"version-history":[{"count":2,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/646\/revisions"}],"predecessor-version":[{"id":662,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=\/wp\/v2\/posts\/646\/revisions\/662"}],"wp:attachment":[{"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.kylelv.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}