小明是个急性子,上小学的时候经常把老师写在黑板上的题目抄错了。
有一次,老师出的题目是:36 x 495 = ?36x495=?
他却给抄成了:396 x 45 = ?396x45=?
但结果却很戏剧性,他的答案竟然是对的!!
因为 36 * 495 = 396 * 45 = 1782036∗495=396∗45=17820。
类似这样的巧合情况可能还有很多,比如:27 * 594 = 297 * 5427∗594=297∗54。
假设 a\ b\ c\ d\ ea b c d e 代表 11 ~ 99 不同的 55 个数字(注意是各不相同的数字,且不含 00 )
能满足形如: ab * cde = adb * ceab∗cde=adb∗ce 这样的算式一共有多少种呢?
s = 0 # 记录总数
# 枚举 a、b、c、d、e 所有可能的数字组合
for a in range(1, 10):
for b in range(1, 10):
if b == a:
continue
for c in range(1, 10):
if c in [a, b]:
continue
for d in range(1, 10):
if d in [a, b, c]:
continue
for e in range(1, 10):
if e in [a, b, c, d]:
continue
# 计算 ab * cde 和 adb * ce 的值
x = a * 10 + b
y = c * 100 + d * 10 + e
z = a * 100 + d * 10 + b
w = c * 10 + e
if x * y == z * w: # 如果相等,则记录下来
s += 1
print(f"{s} ")