自己写的。8/11=1/11+1/11+1/11。。。。。。

将真分数分解为埃及分数

https://www.nowcoder.com/practice/e0480b2c6aa24bfba0935ffcca3ccb7b

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextLine()) {
            String[] str = in.nextLine().split("\\/");
            int up = Integer.valueOf(str[0]);
            String res = "";
            for (int i = 1; i < up; i++) {
                res += ("1/" + str[1] + "+");
            }
            res += ("1/" + str[1]);
            System.out.println(res);
        }
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务