文章目錄

原题链接 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的组成方式一共有多少种?

解法:

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

文章目錄