Project euler problem 31 - 40

原创 2009年06月26日 16:02:00

Problem 31

22 November 2002

 

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 + 1× 50p + 2× 20p + 1× 5p + 1× 2p + 3× 1p

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

 

分析:用递归

 

Problem 32

06 December 2002

 

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只能是1位或2位,b只能是3位或4位,所以循环就很简单了

Problem 33

20 December 2002

The fraction ^( 49 ) /_( 98 ) is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that ^( 49 ) /_( 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.

 

分析:经过简单分析,只有形如ax/xb = a/b有解

 

Problem 34

03 January 2003

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.

 

分析:实际上有 9!=362880,362880*n<10^n 可算出上限,剩下的暴力

 

 

Problem 35

17 January 2003

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?

 

分析:1位数数字易得,2位数以上,实际上是1,3,7,9的组合,这里程序用到了组合,代码有点长,但是快。

 

 

Problem 36

31 January 2003

The decimal number, 585 = 1001001001_( 2 ) (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.)

 

分析:求的是1000000以下的数字,在二进制及十进制情况下均是回文数,偶数当然不行(2进制下最后是0,所以T掉)

 

Problem 37

14 February 2003

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.

 

分析:判断这个数是否素数(并置于一个数组中),然后再从左到右或从右到左,判断素数数组是否含有该数

 

Problem 38

28 February 2003

Take the number 192 and multiply it by each of 1, 2, and 3:

192 × 1 = 192
192 × 2 = 384
192 × 3 = 576

By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product of 192 and (1,2,3)

The same can be achieved by starting with 9 and multiplying by 1, 2, 3, 4, and 5, giving the pandigital, 918273645, which is the concatenated product of 9 and (1,2,3,4,5).

What is the largest 1 to 9 pandigital 9-digit number that can be formed as the concatenated product of an integer with (1,2, ... , n ) where n > 1?

 

分析:用笔算出每种位数的上下限即可

 

 

Problem 39

14 March 2003

If p is the perimeter of a right angle triangle with integral length sides, {a ,b ,c }, there are exactly three solutions for p = 120.

{20,48,52}, {24,45,51}, {30,40,50}

For which value of p ≤ 1000, is the number of solutions maximised?

 

分析:没太多,勾股定理暴力

 

Problem 40

28 March 2003

An irrational decimal fraction is created by concatenating the positive integers:

0.123456789101 112131415161718192021...

It can be seen that the 12^( th ) digit of the fractional part is 1.

If d _( n ) represents the n ^( th ) digit of the fractional part, find the value of the following expression.

d _( 1 ) × d _( 10 ) × d _( 100 ) × d _( 1000 ) × d _( 10000 ) × d _( 100000 ) × d _( 1000000

分析:此题因为有了StringBuffer这个类,我就没去思考了,所以代码读起来没技术含量。

这个网站后面很多用到的数学知识及算法对我来说有点困难,唉,啃这些书真累。。。

欧拉回路(Euler Circuit)

定义:若一副图中从某个顶点A走出,经过图中的所有的边,且每条边只经过一次,则称这个环为欧拉回路,如果某幅图含有这样的环,则这幅图叫做欧拉图。 如何判断一幅图是不是欧拉图,也即一幅图中是否含有欧拉回路...
  • shaya118
  • shaya118
  • 2014年12月09日 23:15
  • 1566

Project Euler18题 从上往下邻接和

题目:By starting at the top of the triangle below and moving to adjacent numbers on the row below, the...
  • jiang111_111shan
  • jiang111_111shan
  • 2015年07月16日 09:06
  • 757

project euler problem 29数的多次幂的重复个数

Distinct powers Problem 29 Consider all integer combinations of ab for 2  a  5 and 2  b ...
  • u011466175
  • u011466175
  • 2013年10月20日 13:35
  • 603

极光推送的使用

极光推送的使用
  • zhangying1994
  • zhangying1994
  • 2016年07月03日 14:30
  • 1584

构建Spring源码问题总结

自己动手构建spring源码来追踪源码的实现流程和查看源码。
  • XIAOHAOGE2013
  • XIAOHAOGE2013
  • 2015年08月07日 11:54
  • 835

project Euler上的一些问题

随便做了几题,还是project first,有空再来做 Number spiral diagonals问题 21 22 23 24 25 20  7  8  9 10 19  6  1  2 ...
  • zhanglei0107
  • zhanglei0107
  • 2013年07月01日 21:41
  • 616

【安卓学习之常见问题】 使用Eclipse clean时,出现“cleaning all project has encountered a problem”提示

在使用Eclipse时,经常需要clean下工程,结果每次clean都提示:“cleaning all project has encountered a problem. Errors occurr...
  • ljb568838953
  • ljb568838953
  • 2016年09月18日 09:19
  • 3350

各种语言版本实现欧拉猜想 Euler's sum of powers conjecture

Euler's sum of powers conjecture There is a conjecture in mathematics that held for over 200 ...
  • GarfieldEr007
  • GarfieldEr007
  • 2016年01月07日 12:44
  • 527

Project Euler 练习题希望自己坚持下去

附上在线IDE http://www.shucunwang.com/RunCode/cpp/ 1#include using namespace std; int main() { ...
  • M_S_C
  • M_S_C
  • 2016年12月19日 16:45
  • 218

[置顶] Project Euler Problem 80-高精度开方-牛顿逼近法

It is well known that if the square root of a natural number is not an integer, then it is irrationa...
  • cwjcsu
  • cwjcsu
  • 2013年07月01日 17:14
  • 439
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Project euler problem 31 - 40
举报原因:
原因补充:

(最多只允许输入30个字)