华为OD机试E卷-出租车计费(100分) JAVA

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] nums = Arrays.stream(in.nextLine().split("")).mapToInt(Integer::parseInt).toArray();
        System.out.println(calculate_price(nums));
    }

    private static int calculate_price(int[] nums) {
        int actual = 0;
        for (int num : nums) {
            actual = actual * 9 + num;
            if (num > 4) {
                actual -= 1;
            }
        }
        return actual;
    }

全部评论

相关推荐

xtu大迫杰:偶遇校友,祝校友offer打牌
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
03-19 10:38
实力求职者:真的绷不住了,第一张霸总人设,第二张求生欲拉满
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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