Problem 67 » 履歴 » バージョン 1
Noppi, 2024/01/29 13:45
| 1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
|---|---|---|---|
| 2 | # [[Problem 67]] |
||
| 3 | |||
| 4 | ## Maximum Path Sum II |
||
| 5 | By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. |
||
| 6 | |||
| 7 | <p style="text-align:center"><span style="color:red"><b>3</b></span><br><span style="color:red"><b>7</b></span> 4<br> |
||
| 8 | 2 <span style="color:red"><b>4</b></span> 6<br> |
||
| 9 | 8 5 <span style="color:red"><b>9</b></span> 3</p> |
||
| 10 | |||
| 11 | That is, 3 + 7 + 4 + 9 = 23. |
||
| 12 | |||
| 13 | Find the maximum total from top to bottom in [triangle.txt](https://projecteuler.net/resources/documents/0067_triangle.txt) (right click and 'Save Link/Target As...'), a 15K text file containing a triangle with one-hundred rows. |
||
| 14 | |||
| 15 | <b>NOTE:</b> This is a much more difficult version of [[Problem 18]]. It is not possible to try every route to solve this problem, as there are 2<sup>99</sup> altogether! If you could check one trillion (10<sup>12</sup>) routes every second it would take over twenty billion years to check them all. There is an efficient algorithm to solve it. ;o) |
||
| 16 | |||
| 17 | ## 最大経路の和 その2 |
||
| 18 | 以下の三角形の頂点から下まで移動するとき, その数値の合計の最大値は23になる. |
||
| 19 | |||
| 20 | <p style="text-align:center"><span style="color:red"><b>3</b></span><br><span style="color:red"><b>7</b></span> 4<br> |
||
| 21 | 2 <span style="color:red"><b>4</b></span> 6<br> |
||
| 22 | 8 5 <span style="color:red"><b>9</b></span> 3</p> |
||
| 23 | |||
| 24 | この例では 3 + 7 + 4 + 9 = 23 |
||
| 25 | |||
| 26 | 100列の三角形を含んでいる15Kのテキストファイル [triangle.txt](https://projecteuler.net/resources/documents/0067_triangle.txt) (右クリックして, 『名前をつけてリンク先を保存』)の上から下まで最大合計を見つけよ. |
||
| 27 | |||
| 28 | 注:これは, [[Problem 18]]のずっと難しいバージョンです. |
||
| 29 | 全部で2<sup>99</sup> 通りの組み合わせがあるので, この問題を解決するためにすべてのルートをためすことは可能でありません! |
||
| 30 | あなたが毎秒1兆本の(10<sup>12</sup>)ルートをチェックすることができたとしても, 全てをチェックするために200億年以上かかるでしょう. |
||
| 31 | 解決するための効率的なアルゴリズムがあります. ;o) |
||
| 32 | |||
| 33 | ```scheme |
||
| 34 | ``` |