{"id":4473,"date":"2018-12-26T22:42:52","date_gmt":"2018-12-26T19:42:52","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4473"},"modified":"2018-12-27T18:13:58","modified_gmt":"2018-12-27T15:13:58","slug":"e-olymp-622-%d0%b5%d0%b4%d0%b8%d0%bd%d0%b8%d1%86%d1%8b","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4473","title":{"rendered":"e-olymp 622. \u0415\u0434\u0438\u043d\u0438\u0446\u044b"},"content":{"rendered":"<h1>\u0415\u0434\u0438\u043d\u0438\u0446\u044b<\/h1>\n<p>\u041d\u0430 \u0443\u0440\u043e\u043a\u0430\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438 \u0432\u0430\u0441, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0443\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B2%D0%BE%D0%B8%D1%87%D0%BD%D0%B0%D1%8F_%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D0%B0_%D1%81%D1%87%D0%B8%D1%81%D0%BB%D0%B5%D0%BD%D0%B8%D1%8F\">\u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430<\/a>.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u041e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $n$ $(0 \u2264 n \u2264 2 \\cdot 10^{9})$.<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0447\u0438\u0441\u043b\u0430 $n$.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tbody>\n<tr>\n<td>\u0412\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/td>\n<td>\u0412\u042b\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/td>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td>0<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>2000000000<\/td>\n<td>13<\/td>\n<\/tr>\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.*;\r\nimport java.lang.*;\r\nimport java.io.*;\r\nimport 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 k=0, n;\r\n\t\tScanner in = new Scanner(System.in);\r\n\t\tn = in.nextInt();\r\n\t\twhile (n &gt; 0){   \r\n\t\t\tk += (n % 2);\r\n\t\t\tn = n \/ 2;\r\n\t\t}\r\n\t\tSystem.out.print(k);\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u043c \u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 $n$ \u043d\u0430 $2$ \u0438 \u043d\u0430\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f (\u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e), \u0440\u0430\u0432\u043d\u044b\u0445 \u0435\u0434\u0438\u043d\u0438\u0446\u0435. \u041f\u043e\u043b\u0430\u0433\u0430\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 $k$ \u0440\u0430\u0432\u043d\u043e\u0435 \u043d\u0443\u043b\u044e. \u0417\u0430\u0442\u0435\u043c, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043a \u0438\u043c\u0435\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0443 \u043d\u0430\u0441 $k$. \u0415\u0441\u043b\u0438 \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u0440\u0430\u0432\u0435\u043d \u0435\u0434\u0438\u043d\u0438\u0446\u0435 \u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c $k+1$ \u0447\u0442\u043e \u043d\u0430\u043c \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/622\">e-olimp<\/a><br \/>\n\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f <a href=\"https:\/\/ideone.com\/S7PTSt\">ideon<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0415\u0434\u0438\u043d\u0438\u0446\u044b \u041d\u0430 \u0443\u0440\u043e\u043a\u0430\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u043a\u0438 \u0432\u0430\u0441, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0443\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u043e\u0434\u043d\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0435 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438. \u041f\u0440\u0438\u0448\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u0437\u043d\u0430\u043d\u0438\u044f. \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u041e\u0434\u043d\u043e \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $n$ $(0 \u2264 n \u2264 2 \\cdot 10^{9})$. \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0435\u0434\u0438\u043d\u0438\u0446 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u0438 \u0447\u0438\u0441\u043b\u0430 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4473\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":116,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[624,231],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4473"}],"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\/116"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4473"}],"version-history":[{"count":6,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4473\/revisions"}],"predecessor-version":[{"id":4538,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4473\/revisions\/4538"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}