{"id":838,"date":"2016-07-05T10:37:28","date_gmt":"2016-07-05T07:37:28","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=838"},"modified":"2016-07-08T07:57:20","modified_gmt":"2016-07-08T04:57:20","slug":"e-olymp-109-numeration","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=838","title":{"rendered":"e-olymp 109. Numeration"},"content":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u0437\u044f\u0442\u0430 \u0441 \u0441\u0430\u0439\u0442\u0430 <a href=\"http:\/\/www.e-olymp.com\/ru\/problems\/109\" target=\"_blank\">e-olymp.com<\/a>.<\/p>\n<h1>\u0423\u0441\u043b\u043e\u0432\u0438\u0435<\/h1>\n<p>\u0414\u043b\u044f \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438 <img decoding=\"async\" class=\"latex\" title=\"M\" src=\"http:\/\/s0.wp.com\/latex.php?latex=M&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"M\" \/>\u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043a\u043d\u0438\u0433\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <img decoding=\"async\" class=\"latex\" title=\"N\" src=\"http:\/\/s0.wp.com\/latex.php?latex=N&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"N\" \/>\u00a0\u0446\u0438\u0444\u0440. \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443\u00a0<img decoding=\"async\" class=\"latex\" title=\"N\" src=\"http:\/\/s0.wp.com\/latex.php?latex=N&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"N\" \/>\u00a0\u0432\u044b\u0432\u0435\u0441\u0442\u0438 <img decoding=\"async\" class=\"latex\" title=\"M\" src=\"http:\/\/s0.wp.com\/latex.php?latex=M&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"M\" \/>\u00a0\u0438\u043b\u0438 <img decoding=\"async\" class=\"latex\" title=\"0\" src=\"http:\/\/s0.wp.com\/latex.php?latex=0&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"0\" \/>, \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u041d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e <img decoding=\"async\" class=\"latex\" title=\"N\" src=\"http:\/\/s0.wp.com\/latex.php?latex=N&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"N\" \/>. \u0412 \u043a\u043d\u0438\u0433\u0435 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 <img decoding=\"async\" class=\"latex\" title=\"1001\" src=\"http:\/\/s0.wp.com\/latex.php?latex=1001&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"1001\" \/>\u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0418\u0441\u043a\u043e\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b :<\/h2>\n<table>\n<tbody>\n<tr>\n<td>N<\/td>\n<td>8<\/td>\n<td>21<\/td>\n<td>22<\/td>\n<td>113<\/td>\n<td>999<\/td>\n<td>1001<\/td>\n<\/tr>\n<tr>\n<td>M<\/td>\n<td>8<\/td>\n<td>15<\/td>\n<td>0<\/td>\n<td>61<\/td>\n<td>369<\/td>\n<td>0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434 \u043d\u0430 Java:<\/h1>\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) {\r\n\t\tScanner scan = new Scanner(System.in);\r\n\t\tint n = scan.nextInt();\r\n\t\tint m = 1;\r\n\t\twhile (true) {\r\n\t\t\tif (m &lt; 10) {\t\/\/1 digit\r\n\t\t\t\tn -= 1;\r\n\t\t\t} else if (m &lt; 100) {\t\/\/2 digits\r\n\t\t\t\tn -= 2;\r\n\t\t\t} else if (m &lt; 1000) {\t\/\/3 digits\r\n\t\t\t\tn -= 3;\r\n\t\t\t} else {\t\/\/4 digits\r\n\t\t\t\tn -= 4;\r\n\t\t\t}\r\n\t\t\tif (n &lt; 0) {\r\n\t\t\t\tm = 0;\r\n\t\t\t}\r\n\t\t\tif (n &lt;= 0) {\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t\tm++;\r\n\t\t}\r\n\t\tSystem.out.print(m);\r\n\t}\r\n}<\/pre>\n<h1>\u0425\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f:<\/h1>\n<p>\u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446 <img decoding=\"async\" class=\"latex\" title=\"M\" src=\"http:\/\/s0.wp.com\/latex.php?latex=M&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"M\" \/> \u043a\u0430\u043a 1.<br \/>\n\u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 <img decoding=\"async\" class=\"latex\" title=\"M\" src=\"http:\/\/s0.wp.com\/latex.php?latex=M&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"M\" \/>, \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0446\u0438\u0444\u0440 \u0438\u0437 <img decoding=\"async\" class=\"latex\" title=\"N\" src=\"http:\/\/s0.wp.com\/latex.php?latex=N&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"N\" \/>:<\/p>\n<pre class=\"start-line:11 lang:java decode:true \">if (m &lt; 10) {\t\/\/1 digit\r\n\tn -= 1;\r\n} else if (m &lt; 100) {\t\/\/2 digits\r\n\tn -= 2;\r\n} else if (m &lt; 1000) {\t\/\/3 digits\r\n\tn -= 3;\r\n} else {\t\/\/4 digits\r\n\tn -= 4;\r\n}<\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <img decoding=\"async\" class=\"latex\" title=\"N\" src=\"http:\/\/s0.wp.com\/latex.php?latex=N&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"N\" \/>, \u0437\u043d\u0430\u0447\u0438\u0442, \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c, \u0442\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c 0:<\/p>\n<pre class=\"start-line:20 lang:java decode:true \">if (n &lt; 0) {\r\n\tm = 0;\r\n}\r\nif (n &lt;= 0) {\r\n\tbreak;\r\n}<\/pre>\n<p>\u0412\u044b\u0439\u0434\u044f \u0438\u0437 \u0446\u0438\u043a\u043b\u0430, \u0432\u044b\u0432\u043e\u0434\u0438\u043c <img decoding=\"async\" class=\"latex\" title=\"M\" src=\"http:\/\/s0.wp.com\/latex.php?latex=M&amp;bg=292625&amp;fg=b29d85&amp;s=0\" alt=\"M\" \/>:<\/p>\n<pre class=\"start-line:28 lang:java decode:true \">System.out.print(m);<\/pre>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438:<\/h1>\n<p>\u0420\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 Ideone.com:\u00a0<a href=\"http:\/\/ideone.com\/XR4AQk\">Ideone.com<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0432\u0437\u044f\u0442\u0430 \u0441 \u0441\u0430\u0439\u0442\u0430 e-olymp.com. \u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0414\u043b\u044f \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0438 \u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043a\u043d\u0438\u0433\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u00a0\u0446\u0438\u0444\u0440. \u041f\u043e \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u043c\u0443\u00a0\u00a0\u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u00a0\u0438\u043b\u0438 , \u0435\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442. \u041d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e . \u0412 \u043a\u043d\u0438\u0433\u0435 \u043d\u0435 \u0431\u043e\u043b\u0435\u0435 \u00a0\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b. \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 \u0441\u0442\u0440\u0430\u043d\u0438\u0446. \u0422\u0435\u0441\u0442\u044b : N 8 21 22 113 999 1001 M 8 15 0 61 369 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=838\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[125,75],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/838"}],"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\/86"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=838"}],"version-history":[{"count":7,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/838\/revisions"}],"predecessor-version":[{"id":1094,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/838\/revisions\/1094"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=838"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=838"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=838"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}