{"id":693,"date":"2016-07-01T12:10:58","date_gmt":"2016-07-01T09:10:58","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=693"},"modified":"2016-07-06T12:14:48","modified_gmt":"2016-07-06T09:14:48","slug":"e-olymp-388","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=693","title":{"rendered":"e-olymp 388. \u041f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435"},"content":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u00a0<a href=\"http:\/\/www.e-olymp.com\/en\/problems\/388\">e-olymp 388<\/a><\/p>\n<p><a href=\"http:\/\/www.e-olymp.com\/ru\/submissions\/2146332\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/a><\/p>\n<p><strong>\u0423\u0441\u043b\u043e\u0432\u0438\u0435<\/strong><\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex]. \u0411\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435, \u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0435\u0433\u043e \u043d\u0430 <strong>2<\/strong>, \u0435\u0441\u043b\u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435, \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043c <strong>1<\/strong>. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e <strong>1<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 <strong>11\u00a0<\/strong>\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e <strong>12<\/strong>, \u0437\u0430\u0442\u0435\u043c <strong>6<\/strong>, <strong>3<\/strong>, <strong>4<\/strong>, <strong>2<\/strong> \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, <strong>1<\/strong>. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <strong>1<\/strong> \u0438\u0437\u00a0<strong>11<\/strong> \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0434\u0435\u043b\u0430\u0442\u044c <strong>6<\/strong> \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/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 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0434\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f <strong>1<\/strong>.<\/p>\n<p>\u0427\u0438\u0441\u043b\u043e [latex]n(1\\leq n \\leq10^{9}).[\/latex]\n<p><strong>\u0422\u0435\u0441\u0442\u044b<\/strong><\/p>\n<table style=\"height: 130px\" width=\"393\">\n<tbody>\n<tr>\n<td style=\"width: 194px\">\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435(n)<\/td>\n<td style=\"width: 183px\">\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 194px\">11<\/td>\n<td style=\"width: 183px\">6<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 194px\">43<\/td>\n<td style=\"width: 183px\">9<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 194px\">1<\/td>\n<td style=\"width: 183px\">0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u041a\u043e\u0434<\/strong><\/p>\n<pre class=\"lang:java decode:true\">import java.util.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\n\r\nclass Main{\r\n\tpublic static void main (String[] args) throws java.lang.Exception{\r\n\t\tScanner x = new Scanner(System.in);\r\n\t\tint counter = 0;\r\n\t\tint n = x.nextInt();\r\n\t\twhile (n != 1) {\r\n\t\t\tcounter++;\r\n\t\t\tif(n % 2 == 0){\r\n\t\t\t\tn = n \/ 2;\r\n\t\t\t} else {\r\n\t\t\t\tn++;\r\n\t\t\t}\r\n\t\t}\r\n\t\tSystem.out.print(counter);\r\n\t}\r\n}<\/pre>\n<p><strong>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/strong><\/p>\n<p>\u041f\u0443\u0441\u0442\u044c [latex]n[\/latex] \u2013 \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c, \u0430 [latex]counter[\/latex] \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0439. \u0426\u0438\u043a\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0434\u043e \u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043f\u043e\u043a\u0430 [latex]n[\/latex] \u0427\u0442\u043e\u0431 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u043d\u0430 \u0447\u0451\u0442\u043d\u043e\u0441\u0442\u044c\/\u043d\u0435\u0447\u0451\u0442\u043d\u043e\u0441\u0442\u044c, \u0434\u0435\u043b\u0438\u043c \u0435\u0433\u043e \u043f\u043e \u043c\u043e\u0434\u0443\u043b\u044e \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0441 \u043d\u0443\u043b\u0451\u043c. \u0415\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u2013 \u0447\u0451\u0442\u043d\u043e\u0435, \u0442\u043e \u0434\u0435\u043b\u0438\u043c \u0435\u0433\u043e \u043d\u0430 2, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2013 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0438 \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0439 \u043d\u0430 1.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430\u00a0e-olymp 388 \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0437\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u043a\u0430\u043a\u043e\u0435-\u043d\u0438\u0431\u0443\u0434\u044c \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]n[\/latex]. \u0411\u0443\u0434\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: \u0435\u0441\u043b\u0438 \u0447\u0438\u0441\u043b\u043e \u0447\u0435\u0442\u043d\u043e\u0435, \u0442\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043c \u0435\u0433\u043e \u043d\u0430 2, \u0435\u0441\u043b\u0438 \u043d\u0435\u0447\u0435\u0442\u043d\u043e\u0435, \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u043c 1. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0447\u0438\u0441\u043b\u043e 1. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 11\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0447\u0438\u0441\u043b\u043e 12, \u0437\u0430\u0442\u0435\u043c 6, 3, 4, 2 \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, 1. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=693\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[93],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/693"}],"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\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=693"}],"version-history":[{"count":20,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/693\/revisions"}],"predecessor-version":[{"id":1807,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/693\/revisions\/1807"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}