ahalei_15
来源:互联网 发布:cf手游龙拳苍龙数据 编辑:程序博客网 时间:2024/05/16 18:14
请将1~9这9个阿拉伯数字分别填入9个□中。每个数字只能使用一次。使得等式成立。
□□*□□□=□□□□
例如12*483=5796就是一个合理的组合,请问一共所有少种合理的组合?
注意:12*483=5796 与 483*12=5796 是同一种组合!
#!usr/bin/env python# -*- coding: utf-8 -*-def is_same(num_1, num_2, freq_1, freq_2): ''' Judge the elements of two numbers whether they are same or not! Different method of finding same element. ---->ahalei_14 ''' def ls_alpha(num): ''' Prepare for finding same element. ''' return list(str(num)) for i in range(freq_1): for j in range(freq_2): if str(num_1)[i] == str(num_2)[j]: return True elif len(ls_alpha(num_1)) != len(list(set(ls_alpha(num_1)))): return True elif len(ls_alpha(num_2)) != len(list(set(ls_alpha(num_2)))): return Truedef has_zero(num): ''' Judge var_number whether it has 0 or not! ''' for k in str(num): if k == str(0): return Truesize = 0for a in range(10, 100): for b in range(100, 1000): if is_same(a, b, 2, 3) is True or has_zero(a) is True or has_zero(b) is True: continue else: for c in range(1000, 10000): if is_same(a, c, 2, 4) is True or is_same(b, c, 3, 4) is True or has_zero(c) is True: continue elif a*b == c: size += 1 print('{0}={1}*{2}...............size is {3}'.format(c, a, b, size))print('\n', size)
0 0
- ahalei_15
- Linux下which、whereis、locate、find区别与用法实例
- Oracle如何结束事务?
- 一次面试
- UVA 439 骑士(Knight Moves ) 很基础的BFS
- Windows 10 IoT Serials 5
- ahalei_15
- 算术基本定理------比1大的整数N的素因子分解是唯一的
- yii 组装多个条件
- 基于计数排序求中位数问题的O(1)算法(Fraudulent Activity Notifications问题)
- ajax传值写法
- 【VS开发】ClientToScreen 和ScreenToClient 用法
- Vector 介绍
- viewpager的基本用法
- hdu1003(基础dp)