{"id":580,"date":"2024-06-17T09:00:00","date_gmt":"2024-06-17T01:00:00","guid":{"rendered":"https:\/\/seanxd.com\/?p=580"},"modified":"2024-05-12T20:13:42","modified_gmt":"2024-05-12T12:13:42","slug":"zerojudge-a307","status":"publish","type":"post","link":"https:\/\/seanxd.com\/zh\/zerojudge-a307\/","title":{"rendered":"ZeroJudge A307: \u6578\u5b57\u53cd\u8f49"},"content":{"rendered":"\n\n\n<p class=\"\">\u7d66\u5b9a\u4e00\u500b\u6574\u6578\uff0c\u8acb\u5c07\u8a72\u6578\u5404\u4f4d\u4e0a\u6578\u5b57\u53cd\u8f49\u5f97\u5230\u4e00\u500b\u65b0\u6578\u3002 \u65b0\u6578\u4e5f\u61c9\u6eff\u8db3\u6574\u6578\u7684\u5e38\u898b\u5f62\u5f0f\uff0c\u5373\u9664\u975e\u7d66\u5b9a\u7684\u539f\u6578\u70ba\u96f6\uff0c\u5426\u5247\u53cd\u8f49\u5f8c\u5f97\u5230\u7684\u65b0\u6578\u7684\u6700\u9ad8\u4f4d\u6578\u5b57\u4e0d\u61c9\u70ba\u96f6\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7bc4\u4f8b\u6e2c\u8cc7<\/h2>\n\n\n\n<figure class=\"wp-block-table nfd-wb-animate nfd-wb-fade-in-bottom-short\"><table class=\"has-fixed-layout\"><thead><tr><th>\u7bc4\u4f8b\u8f38\u5165<\/th><th>\u7bc4\u4f8b\u8f38\u51fa<\/th><\/tr><\/thead><tbody><tr><td><strong>EOF<\/strong> \u8f38\u5165\uff0c\u6bcf\u7b46\u8f38\u5165\u5171 1 \u884c\uff0c\u4e00\u500b\u6574\u6578 N\u3002<\/td><td>\u8f38\u51fa\u5171 1 \u884c\uff0c\u4e00\u500b\u6574\u6578\uff0c\u8868\u793a\u53cd\u8f49\u5f8c\u7684\u65b0\u6578\u3002<\/td><\/tr><tr><td>123<br>-380<\/td><td>321<br>-83<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u89e3\u984c\u601d\u8def<\/h2>\n\n\n\n<p class=\"\"><strong>\u6536 N \u7684\u6642\u5019\u4f7f\u7528\u6574\u6578\u7684\u578b\u614b\u6536\u8cc7\u6599<\/strong>\uff0c\u4e26\u4e14\u5224\u65b7 N \u662f\u5426\u70ba\u8ca0\u6578\uff0c\u8a2d\u5b9a\u4e00\u500b\u5e03\u6797\u503c\u5b58\u662f\u5426\u70ba\u8ca0\u6578\u3002\u5982\u679c N \u70ba\u8ca0\u6578\uff0c\u5148\u5c07 N *= -1 \u5c07 N \u8b8a\u6210\u6b63\u6578\u3002<\/p>\n\n\n\n<p class=\"\">\u5c07 N \u8f49\u63db\u70ba\u5b57\u4e32\u5f8c reverse\uff0c\u4e26\u518d\u8f49\u63db\u56de\u6574\u6578\u578b\u614b\uff0c\u5982\u679c\u525b\u525b\u5224\u65b7 N \u70ba\u8ca0\u6578\uff0c\u5247\u9700\u8981\u4e58\u4ee5 -1\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u7bc4\u4f8b\u7a0b\u5f0f\u78bc\uff0d<a href=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a307\" data-type=\"link\" data-id=\"https:\/\/zerojudge.tw\/ShowProblem?problemid=a307\" target=\"_blank\" rel=\"noreferrer noopener\">ZeroJudge A307: \u6578\u5b57\u53cd\u8f49<\/a><\/h3>\n\n\n\n<div class=\"hcb_wrap nfd-wb-animate nfd-wb-reveal-right nfd-delay-50\"><pre class=\"prism line-numbers lang-cpp\" data-lang=\"C++\"><code>#include &lt;iostream&gt;\n#include &lt;algorithm&gt;\nusing namespace std;\n\nint main() {\n    cin.sync_with_stdio(0);\n    cin.tie(0);\n    int N;\n    while (cin &gt;&gt; N)\n    {\n        int negative = 1;\n        if (N &lt; 0)\n        {\n            negative = -1;\n            N *= -1;\n        }\n        string str = to_string(N);\n        reverse(str.begin(), str.end());\n        int ans;\n        if (str.length() == 1) ans = int(str[0] - &#39;0&#39;);\n        else ans = stoi(str);\n        ans *= negative;\n        cout &lt;&lt; ans &lt;&lt; &quot;\\n&quot;;\n    }\n}\n\n\/\/ZeroJudge A307\n\/\/Dr. SeanXD<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7d66\u5b9a\u4e00\u500b\u6574\u6578\uff0c\u8acb\u5c07\u8a72\u6578\u5404\u4f4d\u4e0a\u6578\u5b57\u53cd\u8f49\u5f97\u5230\u4e00\u500b\u65b0\u6578\u3002 \u65b0\u6578\u4e5f\u61c9\u6eff\u8db3\u6574\u6578\u7684\u5e38\u898b\u5f62\u5f0f\uff0c\u5373\u9664\u975e\u7d66\u5b9a\u7684\u539f\u6578\u70ba\u96f6\uff0c\u5426\u5247\u53cd\u8f49 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[25],"tags":[8,11,13,12,9],"class_list":["post-580","post","type-post","status-publish","format-standard","hentry","category-ioi-apcs","tag-8","tag-11","tag-13","tag-12","tag-9"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/580","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/comments?post=580"}],"version-history":[{"count":1,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/580\/revisions"}],"predecessor-version":[{"id":581,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/posts\/580\/revisions\/581"}],"wp:attachment":[{"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/media?parent=580"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/categories?post=580"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/seanxd.com\/zh\/wp-json\/wp\/v2\/tags?post=580"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}