{"id":4572,"date":"2018-12-27T18:05:49","date_gmt":"2018-12-27T15:05:49","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4572"},"modified":"2018-12-27T18:17:49","modified_gmt":"2018-12-27T15:17:49","slug":"e-olymp-44-%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%86%d1%8b","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4572","title":{"rendered":"e-olymp 44. \u0415\u0434\u0438\u043d\u0438\u0446\u044b"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-4573 alignright\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/number-1-letters-and-numbers-numbers-93041-300x235.png\" alt=\"\" width=\"147\" height=\"115\" srcset=\"https:\/\/java.mazurok.com\/wp-content\/uploads\/number-1-letters-and-numbers-numbers-93041-300x235.png 300w, https:\/\/java.mazurok.com\/wp-content\/uploads\/number-1-letters-and-numbers-numbers-93041.png 600w\" sizes=\"(max-width: 147px) 100vw, 147px\" \/><br \/>\n\u0412 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e [latex]1[\/latex], \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043a\u043e\u0431\u043a\u0438. \u041a\u0430\u043a\u043e\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex]?<\/p>\n<h1>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u041e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex] [latex](1 \\leqslant n \\leqslant 5000).[\/latex]\n<h1>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0418\u0441\u043a\u043e\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446.<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table>\n<tbody>\n<tr>\n<th>#<\/th>\n<th>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<th>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>7<\/td>\n<td>6<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>22<\/td>\n<td>10<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>90<\/td>\n<td>13<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>157<\/td>\n<td>16<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>985<\/td>\n<td>21<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h1>\n<pre class=\"lang:java decode:true \">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\nimport java.lang.Math;\r\n \r\nclass Main\r\n{\r\n\tpublic static int max = 5001;\r\n\tstatic int [] x = new int[max];\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tScanner in = new Scanner(System.in);\r\n\t\tint n = in.nextInt();\r\n\t\tint k;\r\n\t\tx[1] = 1;\r\n\t\tx[2] = 2;\r\n\t\tfor (int i = 3; i &lt;= n; i++) {\r\n\t\t\tx[i] = x[i-1]+1;\r\n\t\t\tfor (int j = 2; j &lt;= Math.sqrt(n); j++) {\r\n\t\t\t\tif(i % j == 0) {\r\n\t\t\t\t\tk = x[j] + x[i\/j];\r\n\t\t\t\t\tif( k &lt; x[i]) x[i] = x[j] + x[i\/j];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tSystem.out.println(x[n]);\r\n\t}\r\n}<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h1>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e [latex]1,[\/latex] \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u0442\u043e \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u043e\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 [latex]f(i)[\/latex] \u0435\u0434\u0438\u043d\u0438\u0446, \u0430 \u0432\u0442\u043e\u0440\u043e\u0435 &#8212; \u0438\u0437 [latex]f(n-i).[\/latex] \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [latex]i[\/latex] \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u0438\u043c, \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043c\u0430 \u044d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0431\u044b\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439. \u0415\u0441\u043b\u0438 [latex]n[\/latex] \u043d\u0430\u0446\u0435\u043b\u043e \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 [latex]i[\/latex], \u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0439 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0435\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u044c \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 [latex]f(i)[\/latex] \u0435\u0434\u0438\u043d\u0438\u0446, \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; [latex]\\displaystyle f \\left (\\frac{n}{i} \\right).[\/latex] \u0422\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [latex]i[\/latex] \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0431\u0438\u0440\u0430\u0442\u044c \u0434\u043e [latex]\\sqrt{n},[\/latex] \u0447\u0442\u043e\u0431\u044b \u0441\u0443\u043c\u043c\u0430 \u044d\u0442\u0438\u0445 \u0441\u043b\u0430\u0433\u0430\u0435\u043c\u044b\u0445 \u0431\u044b\u043b\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0439. \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d. \u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430.    <\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p>\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/44\" target=\"_blank\" rel=\"noopener\">e-olymp<\/a><br \/>\n\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 <a href=\"https:\/\/ideone.com\/KEmiT7\" target=\"_blank\" rel=\"noopener\">ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0412 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0440\u0435\u0448\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u043b\u043e [latex]1[\/latex], \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u0438 \u0441\u043a\u043e\u0431\u043a\u0438. \u041a\u0430\u043a\u043e\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex]? \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u041e\u0434\u043d\u043e \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex] [latex](1 \\leqslant n \\leqslant 5000).[\/latex] \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0418\u0441\u043a\u043e\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446. \u0422\u0435\u0441\u0442\u044b # \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 1 7 6 2 22 10 3 90 13 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4572\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":123,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[108],"tags":[338,358,632,157],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4572"}],"collection":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/users\/123"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4572"}],"version-history":[{"count":10,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4572\/revisions"}],"predecessor-version":[{"id":4589,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4572\/revisions\/4589"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}