第十届蓝桥杯 JavaB数的分解

思路
从小到大枚举可去重,再判断。
import java.io.*;
public class D数的分解 {
static int[] a = new int[5];
static int count;
static String temp;
public static void main(String[] args) throws FileNotFoundException {
for (int i = 1; i <= 2019; ++i) {
if (check(i))
continue;
for (int j = i + 1; j <= 2019; ++j) {
if (check(j))
continue;
for (int k = j + 1; k <= 2019; ++k) {
if (check(k))
continue;
if (i + j + k == 2019) {
count++;
System.out.println(i + " " + j + " " + k);
}
}
}
}
System.out.println(count);
}
static boolean check(int n) {
String temp = n + "";
for (int i = 0; i < temp.length(); ++i)
if (temp.charAt(i) == '2' || temp.charAt(i) == '4')
return true;
return false;
}
}