topic:
Observe the addition equation below:
Wherein, the same Chinese characters represent the same numbers, and different Chinese characters represent different numbers.
Please fill in the 4-digit number represented by "Sanyang Xianrui" (the only answer), and do not fill in any redundant content.
analyze:
Direct brute force traversal, set "Three Goats Offering Ruixiang Brilliance" as an unknown number, and
its range is [0, 10) or (0, 10). Then traverse and select the result output that meets the conditions.
answer:
public class Main {
public static void main(String[] args) {
int Q, W, E, R, T, Y, U, I, Zoo;
for(int q = 1; q < 10; q++) {
for(int w = 0; w < 10; w++) {
for(int e = 0; e < 10; e++) {
for(int r = 0; r < 10; r++) {
for(int t = 0; t < 10; t++) {
for(int y = 0; y < 10; y++) {
for(int u = 1; u < 10; u++) {
for(int i = 0; i < 10; i++) {
if(q == w || q == e || q == r || q == t || q == y || q == u || q == i || w == e || w == r || w == t || w==y || w==u || w==i || e==r || e==t || e==y || e==u || e==i || r==t || r==y || r==u || r==i || t==y || t==u || t==i || y==u || y==i || u==i ) {
}else {
if((u + q) * 1000 + (r + w) * 100 +(t + e) * 10 + i + r == q * 10000 + w * 1000 + t * 100 + r * 10 + y) {
Q = q;
W = w;
E = e;
R = r;
T = t;
Y = y;
U = u;
I = i;
Zoo = q * 1000 + w * 100 + e * 10 + r;
System.out.println(Zoo);
return;
}
}
}
}
}
}
}
}
}
}
}
}