{"id":1240,"date":"2022-05-31T08:50:34","date_gmt":"2022-05-31T00:50:34","guid":{"rendered":"https:\/\/sanlangcode.com\/?p=1240"},"modified":"2022-05-31T08:50:34","modified_gmt":"2022-05-31T00:50:34","slug":"hj74%e5%9f%83%e5%8f%8a%e5%88%86%e6%95%b0","status":"publish","type":"post","link":"https:\/\/sanlangcode.com\/index.php\/2022\/05\/31\/hj74%e5%9f%83%e5%8f%8a%e5%88%86%e6%95%b0\/","title":{"rendered":"HJ82\u5c06\u771f\u5206\u6570\u5206\u89e3\u4e3a\u57c3\u53ca\u5206\u6570"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u63cf\u8ff0<\/h2>\n\n\n\n<p>\u5206\u5b50\u4e3a1\u7684\u5206\u6570\u79f0\u4e3a\u57c3\u53ca\u5206\u6570\u3002\u73b0\u8f93\u5165\u4e00\u4e2a\u771f\u5206\u6570(\u5206\u5b50\u6bd4\u5206\u6bcd\u5c0f\u7684\u5206\u6570\uff0c\u53eb\u505a\u771f\u5206\u6570)\uff0c\u8bf7\u5c06\u8be5\u5206\u6570\u5206\u89e3\u4e3a\u57c3\u53ca\u5206\u6570\u3002\u5982\uff1a8\/11&nbsp;=&nbsp;1\/2+1\/5+1\/55+1\/110\u3002\u6ce8\uff1a\u771f\u5206\u6570\u6307\u5206\u5b50\u5c0f\u4e8e\u5206\u6bcd\u7684\u5206\u6570\uff0c\u5206\u5b50\u548c\u5206\u6bcd\u6709\u53ef\u80fdgcd\u4e0d\u4e3a1\uff01<br>\u5982\u6709\u591a\u4e2a\u89e3\uff0c\u8bf7\u8f93\u51fa\u4efb\u610f\u4e00\u4e2a\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u5165\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p>\u8f93\u5165\u4e00\u4e2a\u771f\u5206\u6570\uff0cString\u578b<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u8f93\u51fa\u63cf\u8ff0\uff1a<\/h3>\n\n\n\n<p>\u8f93\u51fa\u5206\u89e3\u540e\u7684string<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u793a\u4f8b1<\/h2>\n\n\n\n<p>\u8f93\u5165\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">8\/11\n2\/4<\/pre>\n\n\n\n<p>\u8f93\u51fa\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1\/2+1\/5+1\/55+1\/110\n1\/3+1\/6<\/pre>\n\n\n\n<p>\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u7b2c\u4e8c\u4e2a\u6837\u4f8b\u76f4\u63a5\u8f93\u51fa1\/2\u4e5f\u662f\u53ef\u4ee5\u7684<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.util.Scanner;\n\n\/**\n * \u5148\u5c06 a\/b \u8f6c\u6362\u6210 1\/x+y\/z \u7684\u5f62\u5f0f\n * y\/z \u4f7f\u7528\u9012\u5f52\u7ee7\u7eed\u5206\u89e3\uff0c\u76f4\u5230\u5206\u5b50\u4e3a1\n * \n * b\u9664\u4ee5a\uff0c\u5f97\u5546x\uff0c\u5f97\u4f59\u6570y   b=a*x+y\n * a\/b = 1\/(x+1) + (a-y)\/b(x+1)\n *\/\npublic class Main {\n    public static void main(String&#91;] args) {\n        Scanner sc = new Scanner(System.in);\n\n        while (sc.hasNext()) {\n            String&#91;] str = sc.next().split(\"\/\");\n            \/\/ \u5206\u5b50\n            int a = Integer.parseInt(str&#91;0]);\n            \/\/ \u5206\u6bcd\n            int b = Integer.parseInt(str&#91;1]);\n\n            result = new StringBuffer();\n            process(a, b, result);\n            System.out.println(result);\n        }\n    }\n\n    private static void process(int a, int b, StringBuffer result) {\n        if (result.length() != 0) {\n            result.append(\"+\");\n        }\n\n        int x = b \/ a;\n\n        if (a == 1 || b % a == 0) {\n            result.append(\"1\/\").append(x);\n        } else {\n            int y = b % a;\n            result.append(\"1\/\").append(x + 1);\n            process(a - y, b * (x + 1), result);\n        }\n    }\n\n    static StringBuffer result;\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u63cf\u8ff0 \u5206\u5b50\u4e3a1\u7684\u5206\u6570\u79f0\u4e3a\u57c3\u53ca\u5206\u6570&#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":[4],"tags":[],"class_list":["post-1240","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-4"],"_links":{"self":[{"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1240","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=1240"}],"version-history":[{"count":0,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/posts\/1240\/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=1240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/categories?post=1240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sanlangcode.com\/index.php\/wp-json\/wp\/v2\/tags?post=1240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}