蓝桥杯-古堡算式【枚举】
2018-02-04 23:33
218 查看
福尔摩斯到某古堡探险,看到门上写着一个奇怪的算式:
ABCDE * ? = EDCBA
他对华生说:“ABCDE应该代表不同的数字,问号也代表某个数字!”
华生:“我猜也是!”
于是,两人沉默了好久,还是没有算出合适的结果来。
请利用计算机的优势,找到破解的答案。
把 ABCDE 所代表的数字写出来。
ABCDE * ? = EDCBA
他对华生说:“ABCDE应该代表不同的数字,问号也代表某个数字!”
华生:“我猜也是!”
于是,两人沉默了好久,还是没有算出合适的结果来。
请利用计算机的优势,找到破解的答案。
把 ABCDE 所代表的数字写出来。
#include<stdio.h> int main() { int a,b,c,d,e,x; for( a=0; a<=9; a++) { for( b=0; b<=9; b++) { if(a==b) continue; for( c=0; c<=9; c++) { if(a==b||b==c||a==c) continue; for( d=0; d<=9; d++) { if(a==b||a==c||a==d||b==c||b==d||c==d) continue; for(e=0; e<=9; e++) { if(a==b||a==c||a==d||a==e||b==c||b==d||b==e||c==d||c==e||d==e) continue; for(x=0; x<=9; x++) { int s1=a*10000+b*1000+c*100+d*10+e; int s2=e*10000+d*1000+c*100+b*10+a; if((s1*x)==s2) { printf("%d%d%d%d%d\n",a,b,c,d,e); } } } } } } } return 0; }
相关文章推荐
- 蓝桥杯古堡算式
- 蓝桥杯历届-古堡算式
- 2012蓝桥杯【初赛试题】古堡算式
- 蓝桥杯 历届试题 古堡算式,微生物繁殖
- 古堡算式--爆破(蓝桥杯)
- 蓝桥杯 填符号凑算式 趣味运算 DFS枚举 字符串处理
- 第三届蓝桥杯软件类省赛真题-C-A-2_古堡算式
- 蓝桥杯--2012--古堡算式(暴力)
- 【第三届蓝桥杯】古堡算式
- 蓝桥杯--2012--古堡算式(暴力)
- 2012蓝桥杯省赛(C/C++)A组--古堡算式
- 蓝桥杯 古堡算式
- 古堡算式--蓝桥杯
- 2012蓝桥杯预赛试题本科c++古堡算式
- 蓝桥杯 第三届C/C++预赛真题(2) 古堡算式(数学题)
- 蓝桥杯 古堡算式
- 2012蓝桥杯C++本科 古堡算式
- 古堡算式--蓝桥杯
- 2012年蓝桥杯之古堡算式
- 蓝桥杯--古堡算式