n=abc+acc,a是1-9,b与c是0-9,a b c互不相等,100<n<2000,输出abc
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n = sc.nextInt();
int count=0;
ArrayList<Integer> arr = new ArrayList<>();
for (int i = 100; i < n; i++) {
for (int j = i; j < n; j++) {
if (i+j==n){
String str1=String.valueOf(i);
String str2=String.valueOf(j);
char[] chars1 = str1.toCharArray();
char[] chars2 = str2.toCharArray();
if (chars1.length==3 && chars2.length==3){
if (chars1[0]!=chars1[1] & chars1[1]!=chars1[2] & chars1[0]!=chars1[2] & chars1[0]==chars2[0] & chars1[2]==chars2[2] & chars2[2]==chars2[1]){
count+=1;
arr.add(i);
}
}
}
}
}
Collections.sort(arr);
System.out.println(count);
for (int i = 0; i <arr.size() ; i++) {
if (i==arr.size()-1){
System.out.print(arr.get(i));
}
else{
System.out.print(arr.get(i)+" ");
}
}
}
}
全部评论
(1) 回帖