functools itertools m=a=[,,,,,,,,] list=(itertools.permutations(a,)) n (,functools.reduce(x,y: x*y, (, ))): list2=(list[n]) b=(list2[])*+(list2[])*+(list2[]) c=(list2[])*+(list2[]) d=(list2[])*+(list2[]) e=(list2[])*+(list2[]) (b*c==d*e): m=m+(m,b,c,d,e)
运行结果:
1 134 29 58 67
2 134 29 67 58
3 138 27 54 69
4 138 27 69 54
5 146 29 58 73
6 146 29 73 58
7 158 23 46 79
8 158 23 79 46
9 158 32 64 79
10 158 32 79 64
11 174 23 58 69
12 174 23 69 58
13 174 32 58 96
14 174 32 96 58
15 186 27 54 93
16 186 27 93 54
17 259 18 63 74
18 259 18 74 63
19 532 14 76 98
20 532 14 98 76
21 584 12 73 96
22 584 12 96 73
原文地址:http://pixiuhong.blog.51cto.com/6474245/1826800