I, entitled
Holmes a castle to explore, to see written on the door of a strange equation:
ABCDE * ? = EDCBA
He was born in China, said: "ABCDE should represent different numbers, question marks also on behalf of a digital!"
Watson: "I guess so!"
Thus, the two silent for a long time, or could not calculate the right result.
Please take advantage of the computer, find the crack of the answer.
The figures represent ABCDE write.
Write your answer "answer .txt" Do not write here!
Second, the idea
Direct violence enumeration.
It is noted that, because A is the first number, so the range of 1-9, the range of the other figures 0-9.
Then range "?" Is 2-9
And each number with other numbers can not be the same.
Third, the problem solution
#include <iostream> using namespace std; int main() { for(int a=1;a<=9;a++) { for(int b=0;b<=9;b++) { if(a==b) continue; for (int c=0;c<=9;c++) { if(c==a || c==b) continue; for(int d=0;d<=9;d++) { if(d==c || d==b || d==a) continue; for (int e=0; e<=9;e++) { if(e==d || e==c || e==b || e==a) continue; for(int f=2;f<=9 ;f++) { if(f==e || f==d || f==c || f==b || f==a) continue; if((a*10000+b*1000+c*100+d*10+e)*f == (e*10000+d*1000+c*100+b*10+a)) { cout << a*10000+b*1000+c*100+d*10+e << endl; } } } } } } } return 0; }
Fourth, the results