原题链接 http://projecteuler.net/problem=37

Truncatable primes

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.

Find the sum of the only eleven primes that are both truncatable from left to right and right to left.

NOTE: 2, 3, 5, and 7 are not considered to be truncatable primes.

可截断的素数

数3797有一个有趣的特性。它本身是素数,而且从左到右删除数字依然是素数:3797,797,97和7.类似的,从右到左也是这样:3797,379,37,和3.

求唯一的11个从左到右,从右到左都可截断的素数的和

注意:2,3,5,和7不认为是可截断的素数

解答:

这题没什么好说的。依然是筛法生成素数表,只是不知道素数到底会大到什么程度,所以写的有些丑陋。

联系作者

原题链接 http://projecteuler.net/problem=36

Double-base palindromes

The decimal number, 585 = 1001001001 (binary), is palindromic in both bases.

Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

(Please note that the palindromic number, in either base, may not include leading zeros.)

双进制回文数

对于10进制数,585 = 1001001001(二进制),在两种进制下都是回文数。

求小于1 000 000的数,求所有满足10进制和二进制都是回文数的数的和

(注意,对于所有的回文数,在任何进制中,都不包括开头中的0)

解答:

这题没什么好说的,无非就是进制的转换以及判断回文数。

联系作者

原题链接 http://projecteuler.net/problem=35
Circular primes
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.

There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

How many circular primes are there below one million?

循环素数

对于数字,197,我们称它为循环素数,这是因为旋转数的数字得到的所有数:197,971和719都是素数

100一下一共有13个这种素数:2,3,5,7,11,13,17,31,37,71,73,79和97.

求1000000一下,一共有多少个循环素数?

解答:
关键还是生成一个素数判断表,用筛法。其它没什么好说的。

联系作者

原题链接 http://projecteuler.net/problem=34

Digit factorials

145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.

Find the sum of all numbers which are equal to the sum of the factorial of their digits.

Note: as 1! = 1 and 2! = 2 are not sums they are not included.

数字的阶乘

145是一个特殊的数字,因为1! + 4! + 5! = 1 + 24 + 120 = 145.

求所有满足数的每位数的阶乘之和等于数本身这个条件的数的和
注意:因为1!= 1 和 2!= 2不是和,所以没有被包括进来。

联系作者

原题链接 http://projecteuler.net/problem=33

Digit canceling fractions

The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that49/98 = 4/8, which is correct, is obtained by cancelling the 9s.

We shall consider fractions like, 30/50 = 3/5, to be trivial examples.

There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator.

If the product of these four fractions is given in its lowest common terms, find the value of the denominator.

数字约分

分数49/98是一个特殊的分数,对于一个不熟练的数学爱好者在尝试化简它时,可能会错误地消去9,认为49/98 = 4 / 8,最终的到的结果是正确的。

对于分数30/50 = 3/5,我们认为这是平凡的例子

正好存在4个这种不平凡的分数,它们的值小于1,分子和分母都是两位数。

如果将这四个分数的乘积化简为最简形式,得到的分母是什么?

解答:

这题没什么好说的。

联系作者

原题链接 http://projecteuler.net/problem=32

Pandigital products

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.

全位数乘积
如果一个n位数恰好使用1到n各一次,我们称这个数为全位数;例如,5位数,15234,是一个1到5的全位数。

乘积7254不寻常,对于恒等式 39 * 186 = 7254,包括被乘数,乘数,乘积,正好是一个1到9的全位数

求所有满足被乘数,乘数,乘积这个恒等式是从1到9的全位数这个条件的乘积的和。
提示:有些乘积可以有不只一种形式,要确保只计算一次。
解法:
这题没什么好说的。

联系作者

原题链接 http://projecteuler.net/problem=31

Coin sums

In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:

1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).

It is possible to make £2 in the following way:

1£1 + 150p + 220p + 15p + 12p + 31p

How many different ways can £2 be made using any number of coins?

硬币的和

在英国,货币单位有磅(£),便士(p),一共有八种硬币发行:

1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).

对于£2可以有以下组成形式:

1£1 + 150p + 220p + 15p + 12p + 31p

求£2的组成方式一共有多少种?

解法:

这是一个多重背包问题。两个循环解决问题,注意循环的顺序。

联系作者

原题链接 http://projecteuler.net/problem=30

Digit fifth powers

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:

1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44

As 1 = 14 is not a sum it is not included.

The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

数字的5次幂

令人惊奇的是只存在3个数可以写成数的每位数字的4次幂的和

1634 = 14 + 64 + 34 + 44
8208 = 84 + 24 + 04 + 84
9474 = 94 + 44 + 74 + 44

这里1 = 14 不是和所以没有包括进来

这些数字的和为1634 + 8208 + 9474 = 19316.

求所有满足数的每位数字的5次幂等于数本身这个条件的数的和

解法:

没什么好说的。

联系作者

原题链接 http://projecteuler.net/problem=29

Distinct powers

Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5:

22=4, 23=8, 24=16, 25=32
32=9, 33=27, 34=81, 35=243
42=16, 43=64, 44=256, 45=1024
52=25, 53=125, 54=625, 55=3125

If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by ab for 2 <= a <= 100 and 2 <= b <= 100?

唯一的幂方

考虑ab形式的所有整数,其中2 <= a <= 5,2 <= b <= 5:

22=4, 23=8, 24=16, 25=32
32=9, 33=27, 34=81, 35=243
42=16, 43=64, 44=256, 45=1024
52=25, 53=125, 54=625, 55=3125

如果将它们按大小排序,去除重复数字,我们可以得到如下15个唯一的数:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

求在ab 其中 2 <= a <= 100 ,2 <= b <= 100中,唯一的数有多少个?

解法:

这里用一个set来存。数学方法还没想到。

联系作者

原题链接 http://projecteuler.net/problem=28

Number spiral diagonals

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:

21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13

It can be verified that the sum of the numbers on the diagonals is 101.

What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed in the same way?

数字螺旋的对角线

从1开始向右顺时针方向螺旋得到一个5 * 5的螺旋数如下:

21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13

可以验证对角线上的数之和为101

求以相同形式构成的1001 * 1001的螺旋数的对角线之和。

解答:

这题没什么好说的,就是找规律。

联系作者