代码实现
// num可以分解成几种不同的三个数之和
public static int getNums(int num){
int sum = 0;
for(int i=1;i<num/2;i++){
ArrayList<Integer> list = new ArrayList<>(3);
if(isContains(i)){
continue;
}
for(int j=i+1;j<(num-i+1)/2;j++){
if (isContains(j)) {
continue;
}
if(!isContains(num-i-j)){
System.out.println(i+"-"+j+"-"+(num-i-j));
sum++;
}
}
}
return sum;
}
public static boolean isContains(int num){
String a = String.valueOf(num);
return a.contains("2")||a.contains("4");
}