{"id":3739,"date":"2018-10-28T12:12:56","date_gmt":"2018-10-28T09:12:56","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=3739"},"modified":"2018-11-19T21:38:16","modified_gmt":"2018-11-19T18:38:16","slug":"e-olymp-8-%d1%81%d0%bf%d0%b8%d1%87%d0%ba%d0%b8","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=3739","title":{"rendered":"e-olymp 8. \u0421\u043f\u0438\u0447\u043a\u0438"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u041a\u0430\u043a\u043e\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 [latex]n[\/latex] \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0432 \u043e\u0434\u043d\u0443 \u0441\u043f\u0438\u0447\u043a\u0443? \u0421\u043f\u0438\u0447\u043a\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u043e\u043c\u0430\u0442\u044c \u0438 \u043a\u043b\u0430\u0441\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u0412\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043a\u0438, \u0433\u0434\u0435 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u0446\u044b \u0441\u043f\u0438\u0447\u0435\u043a, \u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c\u0438 \u2013 \u0441\u0430\u043c\u0438 \u0441\u043f\u0438\u0447\u043a\u0438.<\/p>\n<p>\u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 [latex]n[\/latex], \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a.<\/p>\n<h1>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u041e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex] [latex](1 \u2264 n \u2264 10^9)[\/latex].<\/p>\n<h1>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u0434\u043b\u044f \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f [latex]n[\/latex] \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432.<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table>\n<tbody>\n<tr>\n<td>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<td>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<\/tr>\n<tr>\n<td>[latex]1[\/latex]<\/td>\n<td>[latex]4[\/latex]<\/td>\n<\/tr>\n<tr>\n<td>[latex]2[\/latex]<\/td>\n<td>[latex]7[\/latex]<\/td>\n<\/tr>\n<tr>\n<td>[latex]4[\/latex]<\/td>\n<td>[latex]12[\/latex]<\/td>\n<\/tr>\n<tr>\n<td>[latex]7[\/latex]<\/td>\n<td>[latex]20[\/latex]<\/td>\n<\/tr>\n<tr>\n<td>[latex]150[\/latex]<\/td>\n<td>[latex]325[\/latex]<\/td>\n<\/tr>\n<tr>\n<td>[latex]10000[\/latex]<\/td>\n<td>[latex]20200[\/latex]<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<pre class=\"lang:java decode:true \" title=\"e-olymp 8. Matches Solution\">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n\r\nclass Main\r\n{\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\tdouble n = in.nextDouble();\r\n\t\tdouble length = Math.floor(Math.sqrt(n));\r\n\t\tdouble width = Math.ceil(n \/ length);\r\n\t\tdouble k = 2 * n + length + width;\r\n\t\tSystem.out.print((int)(k));\r\n\t}\r\n}<\/pre>\n<p>\u041e\u0434\u0438\u043d \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 [latex]4[\/latex] \u0441\u043f\u0438\u0447\u0435\u043a. \u0414\u0432\u0430 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430 &#8212; \u0438\u0437 [latex]7[\/latex] \u0441\u043f\u0438\u0447\u0435\u043a. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u043b\u0438 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a, \u201c\u0431\u043b\u0438\u0437\u043a\u0438\u0439\u201d \u043a \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0443.<br \/>\n\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 1 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a, \u0447\u0435\u043c \u043d\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0435 2, \u0445\u043e\u0442\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0435:<\/p>\n<ol>\n<li> <img decoding=\"async\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/matches_1.svg\" alt=\"matches_1\" \/> <\/li>\n<li> <img decoding=\"async\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/matches_2.svg\" alt=\"matches_2\" \/> <\/li>\n<\/ol>\n<p>\u0417\u0430\u0434\u0430\u0434\u0438\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u044b \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430. \u041f\u0443\u0441\u0442\u044c [latex]w = \\sqrt n[\/latex] &#8212; \u0435\u0433\u043e \u0448\u0438\u0440\u0438\u043d\u0430. \u041e\u043a\u0440\u0443\u0433\u043b\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [latex]w[\/latex] \u043a \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0446\u0435\u043b\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443, \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u043e\u0435.  \u0422\u043e\u0433\u0434\u0430 \u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 [latex]l = \\displaystyle\\frac {n} {w}[\/latex]. \u0415\u0441\u043b\u0438 \u043e\u043a\u0440\u0443\u0433\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [latex]l[\/latex] \u043a \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u043c\u0443 \u0446\u0435\u043b\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443, \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u043e\u0435, \u0442\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043b\u0438\u0448\u044c \u0442\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u043d\u0430\u0448 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a. \u041e\u043a\u0440\u0443\u0433\u043b\u044f\u044f \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 [latex]l[\/latex] \u043a \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u043c\u0443 \u0446\u0435\u043b\u043e\u043c\u0443 \u0447\u0438\u0441\u043b\u0443, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435 \u043c\u0435\u043d\u044c\u0448\u0435 \u0434\u0430\u043d\u043d\u043e\u0433\u043e, \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b, \u043d\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0432\u0448\u0438\u0435\u0441\u044f \u0432 \u043d\u0430\u0448 \u043f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a.<br \/>\n\u0415\u0441\u043b\u0438 \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u043d\u0438\u0437 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a, \u0440\u0430\u0432\u043d\u043e\u0435 [latex]w[\/latex], \u0438 \u0432\u043f\u0440\u0430\u0432\u043e &#8212; [latex]l[\/latex], \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a (\u0440\u0430\u0437\u0443\u043c\u0435\u0435\u0442\u0441\u044f, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0442\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u043f\u0438\u0447\u0435\u043a \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 [latex]n[\/latex]):<br \/>\n<img decoding=\"async\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/matches_3.svg\" alt=\"matches_3\" \/><br \/>\n\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0440\u0435\u0443\u0431\u0435\u043c\u044b\u0435 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u044b \u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u043b\u043e\u0436\u0438\u0432 &#171;\u0443\u0433\u043e\u043b\u043a\u0438&#187; \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u043f\u0438\u0447\u0435\u043a, \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 \u043b\u0435\u0432\u043e\u0433\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0433\u043b\u0430 \u0438 \u0434\u0432\u0438\u0433\u0430\u044f\u0441\u044c \u0441\u0432\u0435\u0440\u0445\u0443 \u0432\u043d\u0438\u0437 \u0438 \u0441\u043b\u0435\u0432\u0430 \u043d\u0430\u043f\u0440\u0430\u0432\u043e.<br \/>\n&#171;\u0423\u0433\u043e\u043b\u043e\u043a&#187;:<br \/>\n<img decoding=\"async\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/matches_4.svg\" alt=\"matches_4\" \/><br \/>\n\u041e\u0442\u0441\u044e\u0434\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0443\u043b\u0430: [latex]k = 2 \\cdot n + l + w[\/latex], \u0433\u0434\u0435 [latex]k[\/latex] &#8212; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a, \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u043e\u0435 \u0432 \u0437\u0430\u0434\u0430\u0447\u0435.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p><a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/8\" target=\"_blank\" rel=\"noopener\">\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 e-olymp<\/a><br \/>\n<a href=\"https:\/\/ideone.com\/Dook1T\" target=\"_blank\" rel=\"noopener\">\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041a\u0430\u043a\u043e\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043f\u0438\u0447\u0435\u043a \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 [latex]n[\/latex] \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043e\u0439 \u0432 \u043e\u0434\u043d\u0443 \u0441\u043f\u0438\u0447\u043a\u0443? \u0421\u043f\u0438\u0447\u043a\u0438 \u043d\u0435\u043b\u044c\u0437\u044f \u043b\u043e\u043c\u0430\u0442\u044c \u0438 \u043a\u043b\u0430\u0441\u0442\u044c \u0434\u0440\u0443\u0433 \u043d\u0430 \u0434\u0440\u0443\u0433\u0430. \u0412\u0435\u0440\u0448\u0438\u043d\u0430\u043c\u0438 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0442\u043e\u0447\u043a\u0438, \u0433\u0434\u0435 \u0441\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u043a\u043e\u043d\u0446\u044b \u0441\u043f\u0438\u0447\u0435\u043a, \u0430 \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c\u0438 \u2013 \u0441\u0430\u043c\u0438 \u0441\u043f\u0438\u0447\u043a\u0438. \u041d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u043e\u0432 [latex]n[\/latex], \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c, \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0434\u043b\u044f &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=3739\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":131,"featured_media":3740,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[408,198,409],"jetpack_featured_media_url":"https:\/\/java.mazurok.com\/wp-content\/uploads\/maxresdefault1-1024x576.jpg","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3739"}],"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\/131"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3739"}],"version-history":[{"count":4,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3739\/revisions"}],"predecessor-version":[{"id":3748,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3739\/revisions\/3748"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/media\/3740"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}