|
6 | 6 | <title>Best Divisor - √n約数列挙+桁和比較</title> |
7 | 7 |
|
8 | 8 | <!-- Tailwind CSS --> |
9 | | - <script src="https://cdn.tailwindcss.com" crossorigin="anonymous"></script> |
| 9 | + <script src="https://cdn.tailwindcss.com"></script> |
10 | 10 |
|
11 | 11 | <!-- Google Fonts --> |
12 | 12 | <link rel="preconnect" href="https://fonts.googleapis.com" /> |
|
20 | 20 | <link |
21 | 21 | href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" |
22 | 22 | rel="stylesheet" |
23 | | - integrity="sha512-vswe+cgvic/XBoF1OcM/TeJ2FW0OofqAVdCZiEYkd6dwGXthvkSFWOoGGJgS2CW70VK5dQM5Oh+7ne47s74VTg==" |
24 | | - crossorigin="anonymous" |
25 | 23 | /> |
26 | 24 | <link |
27 | 25 | href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" |
28 | 26 | rel="stylesheet" |
29 | | - integrity="sha512-cbQXwDFK7lj2Fqfkuxbo5iD1dSbLlJGXGpfTDqbggqjHJeyzx88I3rfwjS38WJag/ihH7lzuGlGHpDBymLirZQ==" |
30 | | - crossorigin="anonymous" |
31 | 27 | /> |
32 | 28 | <link |
33 | 29 | href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.css" |
34 | 30 | rel="stylesheet" |
35 | | - integrity="sha512-Dqf5696xtofgH089BgZJo2lSWTvev4GFo+gA2o4GullFY65rzQVQLQVlzLvYwTo0Bb2Gpb6IqwxYWtoMonfdhQ==" |
36 | | - crossorigin="anonymous" |
37 | 31 | /> |
38 | 32 |
|
39 | 33 | <style> |
|
83 | 77 | > |
84 | 78 | <h1 class="text-[2.5rem] font-bold text-teal-800 mb-2">Best Divisor</h1> |
85 | 79 | <p class="text-xl text-cyan-700 font-semibold mt-2"> |
86 | | - √n約数列挙+桁和比較 による O(√n) 実装 |
| 80 | + √n約数列挙+桁和比較 による O(√n + d·log n) 実装 |
87 | 81 | </p> |
88 | 82 | <nav class="flex flex-wrap gap-4 mt-6"> |
89 | 83 | <a |
@@ -171,8 +165,8 @@ <h3 class="text-xl font-bold text-teal-800 mt-6 mb-3">戦略</h3> |
171 | 165 | <h3 class="text-xl font-bold text-teal-800 mt-6 mb-3">主要ポイント</h3> |
172 | 166 | <ul class="list-disc list-inside space-y-2 text-slate-700 ml-4"> |
173 | 167 | <li> |
174 | | - <strong>時間計算量:</strong> O(√n) - √n までのループ + O(d log d) |
175 | | - の桁和計算(d は約数の個数) |
| 168 | + <strong>時間計算量:</strong> O(√n + d·log n) - √n までのループ + |
| 169 | + 各約数の桁和計算 O(log n) |
176 | 170 | </li> |
177 | 171 | <li><strong>空間計算量:</strong> O(d) - 約数リストの保存</li> |
178 | 172 | <li> |
@@ -1085,10 +1079,10 @@ <h3 class="text-lg font-bold text-slate-700 mb-3">📖 フローチャートの |
1085 | 1079 | <td class="border-2 border-slate-200 px-4 py-3"> |
1086 | 1080 | <span |
1087 | 1081 | class="px-3 py-1 bg-emerald-100 text-emerald-800 rounded-full font-mono font-bold" |
1088 | | - >O(√n)</span |
| 1082 | + >O(√n + d·log n)</span |
1089 | 1083 | > |
1090 | 1084 | <div class="text-sm text-slate-600 mt-1"> |
1091 | | - √n までループ + O(d log d) 桁和計算 |
| 1085 | + √n までループ + 各約数の桁和計算 O(log n) |
1092 | 1086 | </div> |
1093 | 1087 | </td> |
1094 | 1088 | <td class="border-2 border-slate-200 px-4 py-3"> |
@@ -1214,31 +1208,11 @@ <h3 class="text-xl font-bold text-teal-800 mt-8 mb-3">具体例での計算量</ |
1214 | 1208 | <script src="https://unpkg.com/@babel/standalone/babel.min.js"></script> |
1215 | 1209 |
|
1216 | 1210 | <!-- Prism.js --> |
1217 | | - <script |
1218 | | - src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js" |
1219 | | - integrity="sha512-7Z9J3l1+EYfeaPKcGXu3MS/7T+w19WtKQY/n+xzmw4hZhJ9tyYmcUS+4QqAlzhicE5LAfMQSF3iFTK9bQdTxXg==" |
1220 | | - crossorigin="anonymous" |
1221 | | - ></script> |
1222 | | - <script |
1223 | | - src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js" |
1224 | | - integrity="sha512-AKaNmg8COK0zEbjTdMHJAPJ0z6VeNqvRvH4mfRRWDO9CMxRqi0BlcjWXELn7AbfCvLsZ/SBv8kNEGZOJVdWRCQ==" |
1225 | | - crossorigin="anonymous" |
1226 | | - ></script> |
1227 | | - <script |
1228 | | - src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" |
1229 | | - integrity="sha512-BttltKXFyWnGZQcRWj6osIg7lbizJchuAMotOkdLxHxwt/Hyo+cl47bZU0QADg+Qt5DJwni3SbYGXeGMB5cBcw==" |
1230 | | - crossorigin="anonymous" |
1231 | | - ></script> |
1232 | | - <script |
1233 | | - src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js" |
1234 | | - integrity="sha512-st608h+ZqzliahyzEpETxzU0f7z7a9acN6AFvYmHvpFhmcFuKT8a22TT5TpKpjDa3pt3Wv7Z3SdQBCBdDPhyWA==" |
1235 | | - crossorigin="anonymous" |
1236 | | - ></script> |
1237 | | - <script |
1238 | | - src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js" |
1239 | | - integrity="sha512-/kVH1yrq7ajXhLpvjMxXJqPp6R9w7bqCjW5xhPjGAJTo9JTlx2NjQnM4+Q8dWmjJoMTaYVm7/ZqfqbWLGz+CIQ==" |
1240 | | - crossorigin="anonymous" |
1241 | | - ></script> |
| 1211 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/prism.min.js"></script> |
| 1212 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-python.min.js"></script> |
| 1213 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js"></script> |
| 1214 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/toolbar/prism-toolbar.min.js"></script> |
| 1215 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/copy-to-clipboard/prism-copy-to-clipboard.min.js"></script> |
1242 | 1216 |
|
1243 | 1217 | <!-- React Component --> |
1244 | 1218 | <script type="text/babel"> |
@@ -1967,6 +1941,19 @@ <h3 class="text-xl font-bold text-teal-800 mt-8 mb-3">具体例での計算量</ |
1967 | 1941 | viewBox="0 0 600 250" |
1968 | 1942 | style={{ maxWidth: '100%', height: 'auto', marginTop: '20px' }} |
1969 | 1943 | > |
| 1944 | + <defs> |
| 1945 | + <marker |
| 1946 | + id="step-arrow" |
| 1947 | + markerWidth="10" |
| 1948 | + markerHeight="10" |
| 1949 | + refX="9" |
| 1950 | + refY="3" |
| 1951 | + orient="auto" |
| 1952 | + markerUnits="strokeWidth" |
| 1953 | + > |
| 1954 | + <path d="M0,0 L0,6 L9,3 z" fill="#64748b" /> |
| 1955 | + </marker> |
| 1956 | + </defs> |
1970 | 1957 | {/* Input */} |
1971 | 1958 | <rect |
1972 | 1959 | x="50" |
@@ -2131,7 +2118,7 @@ <h3 class="text-xl font-bold text-teal-800 mt-8 mb-3">具体例での計算量</ |
2131 | 2118 | return () => { |
2132 | 2119 | if (timerRef.current) clearTimeout(timerRef.current); |
2133 | 2120 | }; |
2134 | | - }, [isPlaying, activeStep, stepsData.length]); |
| 2121 | + }, [isPlaying, activeStep]); |
2135 | 2122 |
|
2136 | 2123 | const handlePlay = () => { |
2137 | 2124 | if (isPlaying) return; |
|
0 commit comments