福尔摩斯到某古堡探险,看到门上写着一个奇怪的算式:
ABCDE * ? = EDCBA
他对华生说:“ ABCDE应该代表不同的数字,问号也代表某个数字!”
华生:“我猜也是!”
于是,两人沉默了好久,还是没有算出合适的结果来。
请你利用计算机的优势,找到破解的答案。
把 ABCDE 所代表的数字写出来。
答案写在“解答 .txt”中,不要写在这里!
package mec.lanqiao;
public class Main {
public static void main(String[] args) {
int a, b, c, d, e;
for (int num = 10000; num < 100000; num++) {
a = num / 10000;
b = num / 1000 % 10;
c = num / 100 % 10;
d = num / 10 % 10;
e = num % 10;
if (a < e) {
int reverseNum = e * 10000 + d * 1000 + c * 100 + b * 10 + a;
for (int i = 1; i <= 9; i++) {
if (i * num == reverseNum)
System.out
.println(num + " * " + i + " = " + reverseNum);
}
}
}
}
}
10989 * 9 = 98901
21978 * 4 = 87912
但由于各位数字不同,所以为21987.