将算式变形为除法:DDDDDD/A=ABCAB
枚举范围:A 3-9, D 1-9(A不能取012,否则还是5位数)
一共枚举63次
#include <iostream>
int main()
{
int A, B, C, D;
int total;//代表DDDDDD
int hello;//代表ABCAB
for (A = 3;A <= 9;A++)
{
for (D = 1;D <= 9;D++)
{
total = 100000 * D + 10000 * D + 1000 * D + 100 * D + 10 * D + D;
if (total % A == 0)
{
hello = total / A;
if (hello / 10000 == hello % 100 / 10)
{
if (hello % 10 == hello / 1000 % 10)
{
printf("%d*%d=%d\n", hello, A, total);
}
}
}
}
}
return 0;
}