Problem32

来源:互联网 发布:荷塘月色淘宝论坛网址 编辑:程序博客网 时间:2024/05/19 13:42

We shall say that an n-digit number is pandigital if it makes use of  all the digits 1 to n exactly once; for example, the 5-digit number,  15234, is 1 through 5 pandigital.

 The product 7254 is unusual, as the identity, 39*186 = 7254, containing multiplicand, multiplier, and product is 1 through 9 pandigital.

 Find the sum of all products whose multiplicand/multiplier/product identity can be written as a 1 through 9 pandigital.

HINT: Some products can be obtained in more than one way
so be sure to only include it once in your sum.

* 根据题意分析:
* 因为A*B=C,而且A、B不能等于1,所以C>B,C>A。
* A的位数+B的位数+C的位数=9,所以C大于3位,C>=1000。
* A的位数+B的位数=9-C的位数,若C为4位,则有两种组合(A为1位,B为4位;A为2位,B为3位)可以满足。
* 若C为5位,则A的位数+B的位数=4,不可能满足A*B=C的条件。
*
* 所以C的范围为(1000-9999)
* A/B的范围为(2-4999),因为A、B位置可互换,
* 所以A的取值范围可确定(2-99),B的取值范围(100-4999)

 

 

原创粉丝点击