福尔摩斯到某古堡探险,看到门上写着一个奇怪的算式:
ABCDE * ? = EDCBA
他对华生说:“ABCDE应该代表不同的数字,问号也代表某个数字!”
华生:“我猜也是!”
于是,两人沉默了好久,还是没有算出合适的结果来。
请你利用计算机的优势,找到破解的答案。
把 ABCDE 所代表的数字写出来。
#include "stdio.h"
int main()
{
int i,j;
int temp1,temp2,temp;
int flag,product;
int c[5],a,b;
for(i=10000;i<100000;i++)
for(j=2;j<10;j++)
{
product=j*i;
temp=i;
flag=0;
while(temp!=0 && a<5)
{
temp1=temp%10;
temp2=product/10000;
temp=temp/10;
product=(product-temp2*10000)*10;
if(temp1!=temp2)
{
flag=1;
break;
}
}
temp=i;
while(flag==0)
{
for(a=0;a<5;a++)
{
c[a]=temp%10;
temp=temp/10;
}
for(a=0;a<4;a++)
for(b=a+1;b<5;b++)
{
if(c[a]==c[b])
{
flag=1;
break;
}
}
break;
}
if(flag==0)
printf("%d %d ",i,j);
}
return 0;
}