solution.java 795 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
public class Test004 {

    public static void main(String[] args) {

        for (int a = 111; a <= 333; a++) {
            if (hasZero(a)) {
                continue;
            } else {
                int b = 2 * a;
                int c = 3 * a;
                if (hasZero(b) || hasZero(c)) {
                    continue;
                }

                String s = "" + a + b + c;
                if (isFind(s)) {
                    System.out.print(a + " ");
                }
            }
        }

    }

    private static boolean hasZero(int n) {
        return String.valueOf(n).contains("0");
    }

    private static boolean isFind(String x) {
        char[] arr = x.toCharArray();
        Arrays.sort(arr);
        return "123456789".equals(String.valueOf(arr));

    }
}