Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import itertools
- # 可知y =1 ,而乘数后八位为range(2,10)的全排列。
- # 至此,已经找出乘式中所有元素。
- # first_pair为乘数每一位数 和其与easy相乘的首位数在全排列中的索引对儿元组
- first_pair = [(0, 6), (1, 4), (2, 5), (4, 7), (5, 0), (6, 3), (7, 2)]
- for i in itertools.permutations(range(2, 10)):
- easy = 1 + i[7] * 10 + i[3] * 100 + i[1] * 1000
- math_tuple = i[2:5] + i
- math_str = ''.join(map(str, math_tuple))
- maths = int(math_str)
- x = easy * maths
- if int(i[3] * easy / 10000) != 1:
- continue
- right = True
- for j in first_pair:
- if int(i[j[0]] * easy / 10000) != i[j[1]]:
- right = False
- continue
- if not right:
- continue
- if int(easy * maths / (10**14)) != i[5]:
- continue
- print(easy, " * ", maths)
Advertisement
Add Comment
Please, Sign In to add comment