欧拉工程-问题43
原题链接http://projecteuler.net/problem=43
Sub-string divisibility
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property.
Let d(1)be the 1st digit, d(2) be the 2nd digit, and so on. In this way, we note the following:
d(2)d(3)d(4)=406 is divisible by 2
d(3)d(4)d(5)=063 is divisible by 3
d(4)d(5)d(6)=635 is divisible by 5
d(5)d(6)d(7)=357 is divisible by 7
d(6)d(7)d(8)=572 is divisible by 11
d(7)d(8)d(9)=728 is divisible by 13
d(8)d(9)d(10)=289 is divisible by 17
Find the sum of all 0 to 9 pandigital numbers with this property.
子串可除性
数1406357289是一个0到9的全位数,因为它由0到9组成,每个数字出现一次,它有一个有趣的字串可除性特性
令d(1)为第一个数字,d(2) 为第二个数字,以此类推。这种方式,我们注意如下:
d(2)d(3)d(4)=406可以被2整除
d(3)d(4)d(5)=063可以被3整除
d(4)d(5)d(6)=635可以被5整除
d(5)d(6)d(7)=357可以被7整除
d(6)d(7)d(8)=572可以被11整除
d(7)d(8)d(9)=728可以被13整除
d(8)d(9)d(10)=289可以被17整除
求所有具有这种性质的0到9的全位数的和
解答:
注意观察,观察,再观察,完全可以动手算出这题。而我不会写搜索的,只好写了一个非常丑陋的多重循环。