Project Euler with Ruby on WSL [Problem 31]
解けるけど
ブログに書くのがめんどい問題というのもあるね いや、これがそうなんですが
問題
Coin sums
In the United Kingdom the currency is made up of pound (£) and pence (p). 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?
私訳
コインの和
イギリスにはポンド(£)硬貨とペンス(p)効果が合わせて以下の8種類ある
1p, 2p, 5p, 10p, 20p, 50p, 100p, 200p
合計で 200p をつくる組み合わせはいくつあるか?
解答方針
大きいほうのコインから使用枚数を決めて、 残りの金額を次のコインで割って使用枚数を決めて… とすればよさそう。
注意すべきは残り金額がゼロになったらその先の探索はしない、くらいか