{"id":4143,"date":"2018-12-16T15:40:03","date_gmt":"2018-12-16T12:40:03","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4143"},"modified":"2018-12-25T20:41:03","modified_gmt":"2018-12-25T17:41:03","slug":"e-olymp-165-%d1%81%d0%b8%d0%bc%d0%bc%d0%b5%d1%82%d1%80%d0%b8%d1%8f","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4143","title":{"rendered":"e-olymp 165. \u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u044f"},"content":{"rendered":"<h2>\u0417\u0430\u0434\u0430\u0447\u0430<\/h2>\n<p>\u041f\u0440\u0435\u0434\u043f\u0440\u0438\u0438\u043c\u0447\u0438\u0432\u0430\u044f \u0438 \u0443\u043c\u0435\u043b\u0430\u044f \u0440\u0443\u043a\u043e\u0434\u0435\u043b\u044c\u043d\u0438\u0446\u0430 \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0437\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u00ab\u0444\u0435\u043d\u0435\u0447\u0435\u043a\u00bb \u0438\u0437 \u0431\u0438\u0441\u0435\u0440\u0430. \u041b\u044e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0446\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438 \u0432 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043e\u0440\u043d\u0430\u043c\u0435\u043d\u0442\u0430\u0445 \u0431\u0443\u0441\u0438\u043d\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0432\u0435\u0442\u043e\u0432 (\u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u0446\u0435\u043b\u044b\u043c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c) \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c:<\/p>\n<p>1) \u043f\u0440\u0438 \u0434\u043b\u0438\u043d\u0435 \u0440\u044f\u0434\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0440\u0430\u0432\u043d\u043e\u0439 [latex]1[\/latex] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0443\u0441\u0438\u043d\u043a\u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430;<\/p>\n<p>2) \u043f\u0440\u0438 \u0434\u043b\u0438\u043d\u0435 \u0440\u044f\u0434\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0440\u0430\u0432\u043d\u043e\u0439 [latex]3[\/latex] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0443\u0441\u0438\u043d\u043a\u0438 \u0434\u0432\u0443\u0445 \u0446\u0432\u0435\u0442\u043e\u0432: [latex]1 2 1[\/latex];<\/p>\n<p>3) \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430 \u0441\u0442\u0440\u043e\u0438\u043b\u0441\u044f \u0440\u044f\u0434: [latex]1 2 1 3 1 2 1[\/latex] \u0438 \u0442\u0430\u043a \u0432\u0441\u044f\u043a\u0438\u0439 \u0440\u0430\u0437 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0446\u0432\u0435\u0442\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u0446\u0432\u0435\u0442\u043e\u0432: [latex]1 2 1 3 1 2 1 4 1 2 1 3 1 2 1[\/latex].<\/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\u043c\u043e\u0433\u043b\u0430 \u0431\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u0431\u043e\u0440 \u0446\u0432\u0435\u0442\u0430 \u0431\u0443\u0441\u0438\u043d\u043a\u0438 \u0432 \u0440\u044f\u0434\u0443 \u043f\u043e \u0435\u0451 \u043f\u043e\u0440\u044f\u0434\u043a\u043e\u0432\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443.<\/p>\n<h2><strong>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e [latex]k[\/latex] [latex] (1 \u2264 k \u2264 10^9) [\/latex] \u2013 \u043d\u043e\u043c\u0435\u0440 \u0431\u0443\u0441\u0438\u043d\u043a\u0438, \u0446\u0432\u0435\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0443\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c, \u0432 \u0440\u044f\u0434\u0443 \u0440\u0438\u0441\u0443\u043d\u043a\u0430. \u041d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u0431\u0443\u0441\u0438\u043d\u043e\u043a \u0432 \u0440\u044f\u0434\u0443 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0435\u0434\u0438\u043d\u0438\u0446\u044b.<\/p>\n<h2><strong>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/h2>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u2013 \u043d\u043e\u043c\u0435\u0440 \u0446\u0432\u0435\u0442\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0439 \u0431\u0443\u0441\u0438\u043d\u043a\u0438.<\/p>\n<p>&nbsp;<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tbody>\n<tr>\n<th>#<\/th>\n<th>\u0412\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/th>\n<th>\u0412\u042b\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/th>\n<\/tr>\n<tr>\n<th>1<\/th>\n<th>[latex]10[\/latex]<\/th>\n<th>[latex]2[\/latex]<\/th>\n<\/tr>\n<tr>\n<th>2<\/th>\n<th>[latex]116[\/latex]<\/th>\n<th>[latex]3[\/latex]<\/th>\n<\/tr>\n<tr>\n<th>3<\/th>\n<th>[latex]1[\/latex]<\/th>\n<th>[latex]1[\/latex]<\/th>\n<\/tr>\n<tr>\n<th>4<\/th>\n<th>[latex]454[\/latex]<\/th>\n<th>[latex]2[\/latex]<\/th>\n<\/tr>\n<tr>\n<th>5<\/th>\n<th>[latex]12301230[\/latex]<\/th>\n<th>[latex]2[\/latex]<\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h2>\n<pre class=\"lang:java decode:true \">import java.util.Scanner;\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\tint n, m;\r\n\t\tdouble k;\r\n\t\tScanner scan = new Scanner(System.in);\r\n\t\tn = scan.nextInt();\r\n\t\tm = (int)(Math.log(n)\/Math.log(2));\r\n\t\tk = (double)(Math.log(n)\/Math.log(2));\r\n\t\twhile (m != k){\r\n\t\t\tn = (int)(n - (Math.pow(2,m)));\r\n\t\t\tm = (int)(Math.log(n)\/Math.log(2));\r\n\t\t\tk = (double)(Math.log(n)\/Math.log(2));\r\n\t\t}\r\n\tSystem.out.print(m + 1);\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0420\u0430\u0441\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044f \u0440\u044f\u0434\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u0446\u0432\u0435\u0442\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u0437\u0430\u043a\u043e\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0441\u0442\u044c: \u043a\u0430\u0436\u0434\u044b\u0439 \u0447\u0451\u0442\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043d\u043e\u0432\u044b\u0439 \u0446\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430 \u043c\u0435\u0441\u0442\u0435 [latex]n\u00b72[\/latex]. \u041e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 [latex]n[\/latex] \u0438 [latex]2^{n-1}[\/latex]. \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0434\u043b\u044f \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 &#8212; [latex]\\log_{2}n[\/latex]. \u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043a\u0430\u0442\u044c \u0441\u0440\u0435\u0434\u043d\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0432\u0441\u0435\u0433\u0434\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043d\u0430\u0439\u0434\u0451\u0442 \u043d\u0443\u0436\u043d\u044b\u0439 \u043d\u0430\u043c. \u0414\u043b\u044f \u0447\u0438\u0441\u0435\u043b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0446\u0435\u043b\u044b\u0439 \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043d\u0435\u043b\u044c\u0437\u044f, \u043d\u0430\u0439\u0434\u0435\u043c \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0439 \u043a \u043d\u0435\u043c\u0443 \u0438 \u043e\u0442 \u0447\u0438\u0441\u043b\u0430 \u043e\u0442\u043d\u0438\u043c\u0435\u043c [latex]2[\/latex] \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 [latex]\\log_{2}n[\/latex]. \u041a \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u043c\u0443 \u043e\u0442\u0432\u0435\u0442\u0443 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0434\u0438\u043d\u0438\u0446\u0443, \u0438\u0437-\u0437\u0430 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0439 \u0440\u0430\u043d\u0435\u0435 \u0444\u043e\u0440\u043c\u0443\u043b\u044b [latex]2^{n-1}[\/latex], \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u2022 \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/165\" target=\"_blank\" rel=\"noopener\">e-olymp<\/a>.<\/p>\n<p>\u2022 \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/ideone.com\/NtrqNN\" target=\"_blank\" rel=\"noopener\">ideone<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041f\u0440\u0435\u0434\u043f\u0440\u0438\u0438\u043c\u0447\u0438\u0432\u0430\u044f \u0438 \u0443\u043c\u0435\u043b\u0430\u044f \u0440\u0443\u043a\u043e\u0434\u0435\u043b\u044c\u043d\u0438\u0446\u0430 \u0440\u0435\u0448\u0438\u043b\u0430 \u043f\u043e\u0434\u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438\u0437\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u00ab\u0444\u0435\u043d\u0435\u0447\u0435\u043a\u00bb \u0438\u0437 \u0431\u0438\u0441\u0435\u0440\u0430. \u041b\u044e\u0431\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0446\u0430 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438 \u0432 \u0438\u0441\u043a\u0443\u0441\u0441\u0442\u0432\u0435, \u043e\u043d\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0432 \u0441\u0432\u043e\u0438\u0445 \u043e\u0440\u043d\u0430\u043c\u0435\u043d\u0442\u0430\u0445 \u0431\u0443\u0441\u0438\u043d\u043a\u0438 \u0440\u0430\u0437\u043d\u044b\u0445 \u0446\u0432\u0435\u0442\u043e\u0432 (\u0431\u0443\u0434\u0435\u043c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c \u0446\u0432\u0435\u0442 \u0446\u0435\u043b\u044b\u043c \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0447\u0438\u0441\u043b\u043e\u043c) \u043f\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c: 1) \u043f\u0440\u0438 \u0434\u043b\u0438\u043d\u0435 \u0440\u044f\u0434\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0440\u0430\u0432\u043d\u043e\u0439 [latex]1[\/latex] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0443\u0441\u0438\u043d\u043a\u0443 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0446\u0432\u0435\u0442\u0430; 2) \u043f\u0440\u0438 \u0434\u043b\u0438\u043d\u0435 \u0440\u044f\u0434\u0430 \u0440\u0438\u0441\u0443\u043d\u043a\u0430 \u0440\u0430\u0432\u043d\u043e\u0439 [latex]3[\/latex] \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430 \u0431\u0443\u0441\u0438\u043d\u043a\u0438 \u0434\u0432\u0443\u0445 \u0446\u0432\u0435\u0442\u043e\u0432: [latex]1 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4143\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":115,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[144,547,548,139,158,273,204],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4143"}],"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\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4143"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4143\/revisions"}],"predecessor-version":[{"id":4273,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4143\/revisions\/4273"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4143"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4143"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4143"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}