oj刷题:猜灯谜

jlqwer 发表于 代码 分类,标签:

Description

 A 村的元宵节灯会上有一迷题:


        请猜谜 * 请猜谜 = 请边赏灯边猜


小明想,一定是每个汉字代表一个数字,不同的汉字代表不同的数字。 

请你帮小明把所有的可能的数都找出来吧。

Input

没有输入

Output

提交请猜谜所代表的3位的整数。

Sample Input

没有示例

HINT

只提交3位的整数,不要写其它附加内容,比如:说明性的文字。

如果有多个输出结果,请用采用多行输出的方式。

代码:

 1 #include<stdio.h>
  2 int main()
  3 {
  4     int a,b,c,d,f,m,x,y; /* a=请 b=边 c=赏 d=灯 f=猜 m=迷   */
  5     for(a=1;a<10;a++)
  6     {
  7         for(b=0;b<10;b++)
  8         {
  9             if (a==b)
 10             continue;
 11             for(c=0;c<10;c++)
 12             {
 13                 if (b==c || c==a)
 14                 continue;
 15                 for(d=0;d<10;d++)
 16                 {
 17                     if (d==c || d==b || d==a)
 18                     continue;
 19                     for (f=0;f<10;f++)
 20                     {
 21                         if (f==d || f==c || f==b || f==a)
 22                         continue;
 23                         for(m=0;m<10;m++)
 24                         {
 25                             if (m==f || m==d || m==c || m==b || m==a)
 26                             continue;
 27                                 {
 28                                     x=(a*100+f*10+m);
 29                                     y=(a*100000+b*10000+c*1000+d*100+b*10+f);
 30                                     if ((x*x)==y)
 31                                         printf("%d",x);
 32                                 }
 33                         }
 34                     }
 35                 }
 36
 37             }
 38         }
 39     }
 40     return 0;
 41 }