{"id":1175,"date":"2022-05-28T11:17:49","date_gmt":"2022-05-28T03:17:49","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=1175"},"modified":"2022-05-28T11:17:49","modified_gmt":"2022-05-28T03:17:49","slug":"hj64-mp3%e7%bf%bb%e9%a1%b5-%e6%96%b0%e5%bb%ba%e5%af%b9%e8%b1%a1%e6%a8%a1%e6%8b%9f","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2022\/05\/28\/hj64-mp3%e7%bf%bb%e9%a1%b5-%e6%96%b0%e5%bb%ba%e5%af%b9%e8%b1%a1%e6%a8%a1%e6%8b%9f\/","title":{"rendered":"HJ64-MP3\u7ffb\u9875-\u65b0\u5efa\u5bf9\u8c61\u6a21\u62df"},"content":{"rendered":"\n<p><strong>\u89e3\u9898\u601d\u8def\uff1a<\/strong><\/p>\n\n\n\n<p>\u6a21\u62df\u6574\u4e2a\u8fc7\u7a0b\u5904\u7406\u3002\u60c5\u51b5\u5206\u4e3a\u6b4c\u66f2\u6570\u5c0f\u4e8e\u7b49\u4e8e4\u548c\u5927\u4e8e4\u4e24\u79cd\u60c5\u51b5\uff0c\u6bcf\u79cd\u60c5\u51b5\u90fd\u8981\u8003\u8651\u7279\u6b8a\u7ffb\u9875\u3001\u4e00\u822c\u7ffb\u9875\u3001\u5176\u4ed6\u3002\u7528n\u8868\u793a\u6b4c\u66f2\u603b\u6570\uff0cfirst\u8868\u793a\u5f53\u524d\u9875\u9762\u7684\u7b2c\u4e00\u9996\u6b4c\uff0cnum\u8868\u793a\u5f53\u524d\u9009\u4e2d\u7684\u6b4c\u3002<\/p>\n\n\n\n<p><strong>\u7b97\u6cd5\u6d41\u7a0b<\/strong>\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u5f53\u6b4c\u66f2\u6570\u5c0f\u4e8e\u7b49\u4e8e4\u65f6\uff1a\u7279\u6b8a\u5411\u4e0a\u7ffb\u9875\uff0c\u79fb\u52a8\u5149\u6807\u5230\u6700\u540e\u4e00\u9996\u6b4c\uff1b\u7279\u6b8a\u5411\u4e0a\u7ffb\u9875\uff0c\u79fb\u52a8\u5149\u6807\u5230\u7b2c\u4e00\u9996\u6b4c\uff1b\u4e00\u822c\u5411\u4e0a\u7ffb\u9875\uff0c\u5149\u6807\u5411\u4e0a\u79fb\u52a8\u4e00\u683c\uff1b\u4e00\u822c\u5411\u4e0b\u7ffb\u9875\uff0c\u5149\u6807\u5411\u4e0b\u79fb\u52a8\u4e00\u683c\uff1b<\/li><li>\u5f53\u6b4c\u66f2\u6570\u5927\u4e8e4\u65f6\uff1a\u7279\u6b8a\u5411\u4e0a\u7ffb\u9875\uff0c\u5149\u6807\u79fb\u52a8\u5230\u6700\u540e\u4e00\u9996\u6b4c\uff0c\u6700\u540e\u4e00\u9875\u7b2c\u4e00\u9996\u6b4c\u4e3an-3\uff1b\u7279\u6b8a\u5411\u4e0b\u7ffb\u9875\uff0c\u5149\u6807\u79fb\u52a8\u5230\u7b2c\u4e00\u9996\u6b4c\uff0c\u7b2c\u4e00\u9875\u7b2c\u4e00\u9996\u6b4c\u4e3a1\uff1b\u4e00\u822c\u5411\u4e0a\u7ffb\u9875\uff0c\u5149\u6807\u5411\u4e0a\u79fb\u4e00\u683c\uff0c\u5f53\u524d\u9875\u7b2c\u4e00\u9996\u6b4c\u548c\u5149\u6807\u4f4d\u7f6e\u76f8\u540c\uff1b\u4e00\u822c\u5411\u4e0b\u7ffb\u9875\uff0c\u5149\u6807\u5411\u4e0b\u79fb\u4e00\u683c\uff0c\u5f53\u524d\u9875\u7b2c\u4e00\u9996\u6b4c\u4f4d\u7f6e\u4e5f\u5411\u4e0b\u79fb\u4e00\u683c\uff1b<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\npublic class Main {\n\n    public static void main(String&#91;] args) {\n\n        Scanner sc = new Scanner(System.in);\n        int n = sc.nextInt();\n        String ops = sc.next();\n\n        \/\/ \u6a21\u62df\u7ffb\u9875\n        Page page = new Page(n);\n        for (int i = 0; i &lt; ops.length(); i++) {\n            if ('U' == ops.charAt(i)) {\n                page.up();\n            } else {\n                page.down();\n            }\n        }\n\n        \/\/ \u8f93\u51fa\u7ed3\u679c\n        for (int i = page.top; i &lt;= page.floor; i++) {\n            System.out.print(i);\n            if (i != page.floor) {\n                System.out.print(\" \");\n            }\n        }\n        System.out.println();\n        System.out.println(page.cur);\n    }\n\n}\n\n\/\/ \u6a21\u62df\u7ffb\u9875\u5bf9\u8c61\nclass Page {\n\n    int top;\n    int floor;\n    final int n;\n    int cur;\n\n    public Page(int n) {\n        this.n = n;\n        cur = top = 1;\n        floor = Math.min(n, 4);\n    }\n\n    public void up() {\n\n        cur --;\n        if (cur == 0) {\n            cur = n;\n        }\n\n        if (n > 4) {\n            if (cur == n) {\n                floor = n;\n                top = n - 3;\n            } else if (cur &lt; top) {\n                top --;\n                floor --;\n            }\n        }\n    }\n\n    public void down() {\n\n        cur ++;\n        if (cur == n + 1) {\n            cur = 1;\n        }\n\n        if (n > 4) {\n            if (cur == 1) {\n                top = 1;\n                floor = 4;\n            } else if (cur > floor) {\n                top ++;\n                floor ++;\n            }\n        }\n    }\n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u9898\u601d\u8def\uff1a \u6a21\u62df\u6574\u4e2a\u8fc7\u7a0b\u5904\u7406\u3002\u60c5&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":1122,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,4],"tags":[],"class_list":["post-1175","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","category-4"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/comments?post=1175"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1175\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media\/1122"}],"wp:attachment":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/media?parent=1175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}