-
Notifications
You must be signed in to change notification settings - Fork 0
/
lanqiao huiwen
44 lines (31 loc) · 1.24 KB
/
lanqiao huiwen
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
35
36
37
38
39
40
41
42
43
44
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num = in.nextInt();
List<Integer> list = new ArrayList<Integer>();
for(int i=10000;i<100000;i++) {
String str = Integer.toString(i);
if(str.charAt(0)==str.charAt(4)&&str.charAt(1)==str.charAt(3)) {
if(Character.getNumericValue(str.charAt(0))+Character.getNumericValue(str.charAt(1))+Character.getNumericValue(str.charAt(2))+Character.getNumericValue(str.charAt(3))+Character.getNumericValue(str.charAt(4))==num) {
list.add(i);
}
}
}
for(int i=100000;i<=1000000;i++) {
String str = Integer.toString(i);
if(str.charAt(0)==str.charAt(5)&&str.charAt(1)==str.charAt(4)&&str.charAt(2)==str.charAt(3)) {
if(Character.getNumericValue(str.charAt(0))+Character.getNumericValue(str.charAt(1))+Character.getNumericValue(str.charAt(2))+Character.getNumericValue(str.charAt(3))+Character.getNumericValue(str.charAt(4))+Character.getNumericValue(str.charAt(5))==num) {
list.add(i);
}
}
}
Collections.sort(list);
for(int number : list) {
System.out.println(number);
}
}
}