{"id":215,"date":"2025-03-29T11:15:01","date_gmt":"2025-03-29T11:15:01","guid":{"rendered":"http:\/\/west.wangyuansheng.cn\/?p=215"},"modified":"2025-03-29T12:31:38","modified_gmt":"2025-03-29T12:31:38","slug":"%e7%a5%9e%e5%a5%87%e7%9a%84%e5%ad%97%e6%af%8d%e5%ba%8f%e5%88%97magic","status":"publish","type":"post","link":"http:\/\/west.wangyuansheng.cn\/?p=215","title":{"rendered":"\u795e\u5947\u7684\u5b57\u6bcd\u5e8f\u5217(magic)"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">\u9898\u76ee\u63cf\u8ff0\uff1a<\/h1>\n\n\n\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u7531\u201dL&#8221;\uff0c&#8221;C\u201c\uff0c\u201dR\u201c\u4e09\u4e2a\u5b57\u6bcd\u7ec4\u6210\u7684\u5faa\u73af\u5e8f\u5217\uff1a\u201cLCRLCRLCRLC\u22ef\u201d\uff0c\u8fd9\u4e2a\u5e8f\u5217\u7684\u5faa\u73af\u8282\u4e3a\u201cLCR\u201d\u3002 \u73b0\u5728\u7ed9\u5b9a\u4e00\u4e2a\u6570\u5b57n\uff0c\u8bf7\u6c42\u51fa\u8fd9\u4e2a\u5e8f\u5217\u7684\u7b2cn\u4f4d\u662f\u54ea\u4e2a\u5b57\u6bcd\u3002<br>\u8f93\u5165\u683c\u5f0f\uff1a (magic.in)<br>\u5355\u4e2a\u6574\u6570\uff1a\u8868\u793a n\u3002<br>\u8f93\u51fa\u683c\u5f0f\uff1a (magic.out)<br>\u5355\u4e2a\u5b57\u7b26\uff1a\u8868\u793a\u5b57\u6bcd\u5e8f\u5217\u7684\u7b2cn\u4e2a\u5b57\u6bcd\u3002<br>\u8f93\u5165\u8f93\u51fa\u6837\u4f8b<br>\u8f93\u5165\u6837\u4f8b#1\uff1a<br>5<br>\u8f93\u51fa\u6837\u4f8b#1\uff1a<br>C<br>\u6570\u636e\u8303\u56f4\uff1a<br>\u5bf9\u4e8e 50%\u7684\u6570\u636e\uff0c1\u2264n\u22641,000,000<br>\u5bf9\u4e8e 100%\u7684\u6570\u636e\uff0c1\u2264n\u22641,000,000,000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5206\u6790\u95ee\u9898<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u53d1\u73b0\u89c4\u5f8b\uff0cLCR LCR LCR \u4ee5\u4e00\u5b9a\u7684\u89c4\u5f8b\u51fa\u73b0\uff0c\u4ed4\u7ec6\u89c2\u5bdf\uff0c\u4e0d\u96be\u53d1\u73b0\uff0c\u8fd9\u4e2a\u89c4\u5f8b\u662f\u6bcf\u95f4\u96943\u5c31\u4f1a\u91cd\u65b0\u51fa\u73b0\uff0c\u6240\u4ee5\u5f53\u8f93\u5165\u7684\u6570\u5b57\uff0c\u5c063\u7684\u6574\u6570\u500d\u5ffd\u7565\u6389\uff0c\u6839\u636e\u4f59\u4e0b\u76841\u30012\u30010 \u5224\u65ad\u8f93\u51fa\u4ec0\u4e48\u5b57\u6bcd\u3002<\/p>\n\n\n\n<p>\u77e5\u8bc6\u70b9\uff1a1. <code>int<\/code> \u7c7b\u578b\u7684\u6570\u636e\u8303\u56f4<\/p>\n\n\n\n<p>\u5728\u5e38\u89c1\u7684 32 \u4f4d\u7f16\u8bd1\u5668\u73af\u5883\u4e0b\uff0c<code>int<\/code> \u7c7b\u578b\u901a\u5e38\u5360\u636e 4 \u4e2a\u5b57\u8282\uff0832 \u4f4d\uff09\u7684\u5b58\u50a8\u7a7a\u95f4\u3002\u5b83\u7684\u53d6\u503c\u8303\u56f4\u662f -2,147,483,648 \u5230 2,147,483,647\u3002\u7531\u4e8e\u7ed9\u5b9a\u7684\u6570\u636e\u8303\u56f4 1 \u2264 n \u2264 1,000,000,000 \u5904\u4e8e <code>int<\/code> \u7c7b\u578b\u7684\u6b63\u6570\u533a\u95f4\u5185\uff0c\u6240\u4ee5\u4f7f\u7528 <code>int<\/code> \u7c7b\u578b\u80fd\u591f\u5b8c\u5168\u6db5\u76d6\u8fd9\u4e2a\u8303\u56f4\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u5efa\u7acb\u6a21\u578b<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u8f93\u5165\u4e00\u4e2a\u6570\u5b57 n<\/p>\n\n\n\n<p>\u5c06\u6570\u5b57\u5bf93\u8fdb\u884c\u53d6\u4f59\u64cd\u4f5c<\/p>\n\n\n\n<p>\u6839\u636e\u4f59\u6570\u8f93\u51fa\u5b57\u6bcd<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u5199\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;bits\/stdc++.h&gt;\nusing namespace std;\nint main(){\n    int n;\/\/1 \u2264 n \u2264 1,000,000,000 \u5904\u4e8e `int` \u7c7b\u578b\u7684\u6b63\u6570\u533a\u95f4\u5185\n    cin&gt;&gt;n;\n    int tmp;\n    tmp = n%3;\n    if(tmp==1) cout&lt;&lt;\"L\";\n    else if (tmp==2) cout&lt;&lt;\"C\";\n    else cout&lt;&lt;\"R\";\n    return 0;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u4fdd\u5b58\u3001\u7f16\u8bd1\u3001\u8fd0\u884c<\/h2>\n","protected":false},"excerpt":{"rendered":"<p>\u9898\u76ee\u63cf\u8ff0\uff1a \u7ed9\u5b9a\u4e00\u4e2a\u7531\u201dL&#8221;\uff0c&#8221;C\u201c\uff0c\u201dR\u201c\u4e09\u4e2a\u5b57\u6bcd\u7ec4\u6210\u7684\u5faa\u73af\u5e8f\u5217\uff1a\u201cLCRLCRLCRLC\u22ef\u201d\uff0c\u8fd9\u4e2a\u5e8f\u5217\u7684\u5faa\u73af\u8282\u4e3a\u201cLCR\u201d\u3002 \u73b0\u5728\u7ed9\u5b9a\u4e00\u4e2a\u6570\u5b57n\uff0c\u8bf7\u6c42\u51fa\u8fd9\u4e2a\u5e8f\u5217\u7684\u7b2cn\u4f4d\u662f\u54ea\u4e2a\u5b57\u6bcd\u3002\u8f93\u5165\u683c\u5f0f\uff1a&#8230; <a class=\"read-more\" href=\"http:\/\/west.wangyuansheng.cn\/?p=215\">\u9605\u8bfb\u66f4\u591a&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-215","post","type-post","status-publish","format-standard","hentry","category-problem"],"_links":{"self":[{"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/posts\/215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=215"}],"version-history":[{"count":2,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions"}],"predecessor-version":[{"id":217,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=\/wp\/v2\/posts\/215\/revisions\/217"}],"wp:attachment":[{"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=215"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/west.wangyuansheng.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}