自己写的。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);
        }
    }
}

全部评论

相关推荐

09-03 17:49
已编辑
四川大学 供应链管理
迷茫的大四🐶:提前实习有些坑的,卡毕业后薪资以及能力不达预期提前违约这种
我的OC时间线
点赞 评论 收藏
分享
牛客44664404...:把个人技能删了搞这么长干什么!还有你面试要先针对那个公司的技术栈专门去准备,别一问三不知,他需要你会他们公司对口的技术,写这么多不对口没有用
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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