Problem 18 » 履歴 » バージョン 1
Noppi, 2024/01/01 05:15
| 1 | 1 | Noppi | [ホーム](https://redmine.noppi.jp) - [[Wiki|Project Euler]] |
|---|---|---|---|
| 2 | # [[Problem 18]] |
||
| 3 | |||
| 4 | ## Maximum Path Sum I |
||
| 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 | <div style="text-align:center"><span style="color:red">3</span><br /> |
||
| 7 | <span style="color:red">7</span> 4<br /> |
||
| 8 | 2 <span style="color:red">4</span> 6<br /> |
||
| 9 | 8 5 <span style="color:red">9</span> 3</div> |
||
| 10 | That is, $3 + 7 + 4 + 9 = 23$. |
||
| 11 | Find the maximum total from top to bottom of the triangle below: |
||
| 12 | <div style="text-align:center">75<br /> |
||
| 13 | 95 64<br /> |
||
| 14 | 17 47 82<br /> |
||
| 15 | 18 35 87 10<br /> |
||
| 16 | 20 04 82 47 65<br /> |
||
| 17 | 19 01 23 75 03 34<br /> |
||
| 18 | 88 02 77 73 07 63 67<br /> |
||
| 19 | 99 65 04 28 06 16 70 92<br /> |
||
| 20 | 41 41 26 56 83 40 80 70 33<br /> |
||
| 21 | 41 48 72 33 47 32 37 16 94 29<br /> |
||
| 22 | 53 71 44 65 25 43 91 52 97 51 14<br /> |
||
| 23 | 70 11 33 28 77 73 17 78 39 68 17 57<br /> |
||
| 24 | 91 71 52 38 17 14 91 43 58 50 27 29 48<br /> |
||
| 25 | 63 66 04 68 89 53 67 30 73 16 69 87 40 31<br /> |
||
| 26 | 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23</div> |
||
| 27 | **NOTE:** As there are only $16384$ routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a clever method! ;o) |
||
| 28 | |||
| 29 | ## 数字の文字数 |
||
| 30 | 以下の三角形の頂点から下の行の隣接する数字を通って下まで移動するとき, その数値の和の最大値は23になる. |
||
| 31 | <div style="text-align:center"><span style="color:red">3</span><br /> |
||
| 32 | <span style="color:red">7</span> 4<br /> |
||
| 33 | 2 <span style="color:red">4</span> 6<br /> |
||
| 34 | 8 5 <span style="color:red">9</span> 3</div> |
||
| 35 | この例では 3 + 7 + 4 + 9 = 23. |
||
| 36 | 以下の三角形を頂点から下まで移動するとき, その最大の和を求めよ. |
||
| 37 | <div style="text-align:center">75<br /> |
||
| 38 | 95 64<br /> |
||
| 39 | 17 47 82<br /> |
||
| 40 | 18 35 87 10<br /> |
||
| 41 | 20 04 82 47 65<br /> |
||
| 42 | 19 01 23 75 03 34<br /> |
||
| 43 | 88 02 77 73 07 63 67<br /> |
||
| 44 | 99 65 04 28 06 16 70 92<br /> |
||
| 45 | 41 41 26 56 83 40 80 70 33<br /> |
||
| 46 | 41 48 72 33 47 32 37 16 94 29<br /> |
||
| 47 | 53 71 44 65 25 43 91 52 97 51 14<br /> |
||
| 48 | 70 11 33 28 77 73 17 78 39 68 17 57<br /> |
||
| 49 | 91 71 52 38 17 14 91 43 58 50 27 29 48<br /> |
||
| 50 | 63 66 04 68 89 53 67 30 73 16 69 87 40 31<br /> |
||
| 51 | 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23</div> |
||
| 52 | 注: ここではたかだか 16384 通りのルートしかないので, すべてのパターンを試すこともできる. Problem 67 は同じ問題だが100行あるので, 総当りでは解けない. もっと賢い方法が必要である. |
||
| 53 | |||
| 54 | ```scheme |
||
| 55 | ``` |