题解 | #Old Bill#注意没有符合要求的解时要输出0

Old Bill

https://www.nowcoder.com/practice/17a30153e092493e8b4d13f321343927

import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Label:
        while (sc.hasNextInt()) {
            int n = sc.nextInt();
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            for (int i = 9; i > 0; i--) {
                for (int j = 9; j >= 0; j--) {
                    int cost = i * 10000 + a * 1000 + b * 100 + c * 10 + j;
                    if (cost % n == 0) {
                        System.out.println(i + " " + j + " " + cost / n);
                        continue Label;
                    }
                }
            }
            System.out.println(0);
        }
    }
}

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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