文章目录

题目

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.ArrayList;
import java.util.List;
public class Test {
private static String[] is = new String[] {"0","1", "2","3","4","5","6","7","8","9"};
private static int total;
private static int m = 10;
public static void main(String[] args) {
List<Integer> iL = new ArrayList<Integer>();
new Test().plzh("", iL, m);
System.out.println("total : " + total);
}
private void plzh(String s, List<Integer> iL, int m) {
if(m == 0) {
s = s.substring(1);
// System.out.println(s);
process(s);
total++;
return;
}
List<Integer> iL2;
for(int i = 0; i < is.length; i++) {
iL2 = new ArrayList<Integer>();
iL2.addAll(iL);
if(!iL.contains(i)) {
String str = s +","+ is[i];
iL2.add(i);
plzh(str, iL2, m-1);
}
}
}
private void process(String s){
String strCha[]=s.split(",");
int D=Integer.parseInt(strCha[0]);
int O=Integer.parseInt(strCha[1]);
int N=Integer.parseInt(strCha[2]);
int A=Integer.parseInt(strCha[3]);
int L=Integer.parseInt(strCha[4]);
int G=Integer.parseInt(strCha[5]);
int E=Integer.parseInt(strCha[6]);
int R=Integer.parseInt(strCha[7]);
int B=Integer.parseInt(strCha[8]);
int T=Integer.parseInt(strCha[9]);
int cha[]={D,O,N,A,L,G,E,R,B,T};
if(D*100000+O*10000+N*1000+A*100+L*10+D
+ G*100000+E*10000+R*1000+A*100+L*10+D
== R*100000+O*10000+B*1000+E*100+R*10+T){
int a = D*100000+O*10000+N*1000+A*100+L*10+D;
int b = G*100000+E*10000+R*1000+A*100+L*10+D;
int c = R*100000+O*10000+B*1000+E*100+R*10+T;
System.out.println(" "+a+"\n+"
+b+"\n="
+c);
}
}
}
文章目录