{"id":4121,"date":"2018-12-23T14:19:32","date_gmt":"2018-12-23T11:19:32","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4121"},"modified":"2018-12-25T20:56:12","modified_gmt":"2018-12-25T17:56:12","slug":"e-olymp-9-n-%d0%b7%d0%bd%d0%b0%d1%87%d0%bd%d1%8b%d0%b5-%d1%87%d0%b8%d1%81%d0%bb%d0%b0","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4121","title":{"rendered":"e-olymp 9. N-\u0437\u043d\u0430\u0447\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e $N$-\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440 \u0440\u0430\u0432\u043d\u0430 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e. \u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0441\u0440\u0435\u0434\u0438 \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e $(N&lt;10).$<\/p>\n<h2>\u0412\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0427\u0438\u0441\u043b\u043e  \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0435\u0435 $N.$<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 $2$ \u0447\u0438\u0441\u043b\u0430: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tr>\n<td>\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n<\/td>\n<td>\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n<\/td>\n<\/tr>\n<tr>\n<td>\n$1$\n<\/td>\n<td>\n$10$ $0$\n<\/td>\n<\/tr>\n<tr>\n<td>\n$2$\n<\/td>\n<td>\n$1$ $22$\n<\/td>\n<\/tr>\n<tr>\n<td>\n$4$\n<\/td>\n<td>\n$12$ $1124$\n<\/td>\n<\/tr>\n<tr>\n<td>\n$5$\n<\/td>\n<td>\n$40$ $11125$\n<\/td>\n<\/tr>\n<tr>\n<td>\n$9$\n<\/td>\n<td>\n$144$ $111111129$\n<\/td>\n<\/tr>\n<\/table>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b(\u0426\u0438\u043a\u043b)<\/h2>\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 in = new Scanner(System.in);\r\n\t\tdouble n = in.nextDouble();\r\n\t\tboolean minNumberPrinted = false;\r\n\t\tint count = 0;\r\n\t\tint minNumber = 0;\r\n\t\tif(n == 1) System.out.println(10 + \" \" + 0);\r\n\t\telse {\r\n\t\t\tif(n&gt;1 &amp; n&lt;8) {\r\n\t\t\t\tfor(int i = (int)Math.pow(10, n-1); i  0) {\r\n\t\t\t\t\t\tint digit = number % 10;\r\n\t\t\t\t\t\tsum += digit;\r\n\t\t\t\t\t\tmult *= digit;\r\n\t\t\t\t\t\tnumber \/= 10;\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif(sum == mult &amp; minNumberPrinted == false) {\r\n\t\t\t\t\t\tminNumber = i;\r\n\t\t\t\t\t\tcount++;\r\n\t\t\t\t\t\tminNumberPrinted = true;\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse {\r\n\t\t\t\t\t\tif(sum == mult) count++;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tSystem.out.print(count + \" \" + minNumber);\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tif(n == 8) System.out.print(224 + \" \" + 11111128);\r\n\t\t\t\tif(n == 9) System.out.print(144 + \" \" + 111111129);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438(\u0426\u0438\u043a\u043b)<\/h2>\n<p>\u0414\u043b\u044f c\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 $N=1,$ $N=8$ \u0438 $N=9$ \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0442.\u043a. \u044d\u0442\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043e\u043b\u0433\u043e \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435. \u0414\u043b\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u043c, \u043a\u043e\u0433\u0434\u0430 $1&lt;N&lt;8$ \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c $N$-\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u0417\u0430\u0442\u0435\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 <code>while (number &gt; 0)<\/code> \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u0441\u0443\u043c\u043c\u0430 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0440\u0430\u0432\u043d\u044b \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>minNumberPrinted<\/code> \u0440\u0430\u0432\u043d\u0430 <code>false<\/code>, (\u0442.e. \u043d\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u0435\u0449\u0435 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0438\u0437 \u044d\u0442\u043e\u0439 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u0447\u0442\u043e \u0435\u0433\u043e \u0441\u0443\u043c\u043c\u0430 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440 \u0440\u0430\u0432\u043d\u044b), \u0442\u043e \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <code>minNumber<\/code> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0418\u043d\u0430\u0447\u0435, \u0435\u0441\u043b\u0438 \u0441\u0443\u043c\u043c\u0430 \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0446\u0438\u0444\u0440 \u0447\u0438\u0441\u043b\u0430 \u0440\u0430\u0432\u043d\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0443 $1.$ \u0412\u044b\u0432\u043e\u0434\u0438\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430.<\/p>\n<h2>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u041c\u0430\u0441\u0441\u0438\u0432)<\/h2>\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{\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    \tint[] x = {10,0,1,22,6,123,12,1124,40,11125,30,111126,84,1111127,224,11111128,144,111111129};\r\n    \tint n;\r\n    \tn = in.nextInt();\r\n    \tSystem.out.print(x[2*n-2] + \" \" + x[2*n-1]);\r\n\t}\r\n}\t\r\n<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438(\u041c\u0430\u0441\u0441\u0438\u0432)<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u0432\u0441\u0435 \u043e\u0442\u0432\u0435\u0442\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0438\u0445 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 <code>x<\/code>. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u0442\u0432\u0435\u0442\u044b \u0438\u0434\u0443\u0442 \u043f\u043e\u0434\u0440\u044f\u0434 \u0441\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u0444\u043e\u0440\u043c\u0443\u043b\u0443 \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439: \u0434\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0447\u0438\u0441\u0435\u043b \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u2014 $2n-2,$ \u0434\u043b\u044f \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u2014 $2n-1.$ \u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0448\u0435\u043d\u0430.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\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\/9\">e-olymp<\/a><br \/>\n\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f 1 \u043d\u0430 <a href=\"https:\/\/ideone.com\/I5Pfmu\">ideone.com (\u0446\u0438\u043a\u043b)<\/a><br \/>\n\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f 1 \u043d\u0430 <a href=\"https:\/\/ideone.com\/0qFceL\">ideone.com (\u043c\u0430\u0441\u0441\u0438\u0432)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041d\u0430\u0439\u0442\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e $N$-\u0437\u043d\u0430\u0447\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0443\u043c\u043c\u0430 \u0446\u0438\u0444\u0440 \u0440\u0430\u0432\u043d\u0430 \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044e. \u0412\u044b\u0432\u0435\u0441\u0442\u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0441\u0440\u0435\u0434\u0438 \u0442\u0430\u043a\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e $(N&lt;10).$ \u0412\u0432\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0427\u0438\u0441\u043b\u043e \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0435\u0435 $N.$ \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412 \u0432\u044b\u0445\u043e\u0434\u043d\u043e\u043c \u0444\u0430\u0439\u043b\u0435 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b \u0432\u044b\u0432\u0435\u0441\u0442\u0438 $2$ \u0447\u0438\u0441\u043b\u0430: \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0441\u043a\u043e\u043c\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0441\u0440\u0435\u0434\u0438 \u043d\u0438\u0445. \u0422\u0435\u0441\u0442\u044b \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 $1$ $10$ $0$ $2$ $1$ $22$ $4$ &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4121\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":132,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,25],"tags":[576,575,574],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4121"}],"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\/132"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4121"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4121\/revisions"}],"predecessor-version":[{"id":4326,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4121\/revisions\/4326"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4121"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4121"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4121"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}