{"id":4328,"date":"2018-12-23T17:57:37","date_gmt":"2018-12-23T14:57:37","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4328"},"modified":"2018-12-25T20:59:11","modified_gmt":"2018-12-25T17:59:11","slug":"e-olymp-97-%d1%87%d0%b8%d1%81%d0%bb%d0%b0-%d0%b1%d0%b5%d0%bb%d0%bb%d0%b0","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4328","title":{"rendered":"e-olymp 97. \u0427\u0438\u0441\u043b\u0430 \u0411\u0435\u043b\u043b\u0430"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-3552 alignright\" src=\"http:\/\/java.mazurok.com\/wp-content\/uploads\/Bell..jpg\" alt=\"Bell\" width=\"212\" height=\"123\" \/><br \/>\n\u0427\u0438\u0441\u043b\u043e \u0411\u0435\u043b\u043b\u0430 $B_n$ \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438\u0437 $n$ \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0435\u043f\u0443\u0441\u0442\u044b\u0445 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, $B_3 = 5$, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 $5$ \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 $\\lbrace a, b, c\\rbrace$: $\\lbrace\\lbrace a\\rbrace, \\lbrace b\\rbrace, \\lbrace c\\rbrace\\rbrace, \\lbrace\\lbrace a, b\\rbrace, \\lbrace c\\rbrace\\rbrace, \\lbrace\\lbrace a, c\\rbrace, \\lbrace b\\rbrace\\rbrace, \\lbrace\\lbrace a\\rbrace, \\lbrace b, c\\rbrace\\rbrace, \\lbrace\\lbrace a, b, c\\rbrace\\rbrace$. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e $B_0 = 1$.<br \/>\n\u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c $D_n$:<br \/>\n$$D_n = \\begin{vmatrix}<br \/>\nB_0&amp; B_1&amp; B_2&amp;\\ldots&amp; B_n\\\\<br \/>\nB_1&amp; B_2&amp; B_3&amp;\\ldots&amp; B_{n+1}\\\\<br \/>\n\\ldots&amp; \\ldots&amp; \\ldots&amp; \\ldots&amp; \\ldots\\\\<br \/>\nB_n&amp; B_{n+1}&amp; B_{n+2}&amp;\\ldots&amp; B_{2n}<br \/>\n\\end{vmatrix}$$<br \/>\n\u0414\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 $p$ \u043d\u0430\u0439\u0442\u0438 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0446\u0435\u043b\u043e\u0435 $k$, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e $D_n$ \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 $p^k$.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u041a\u0430\u0436\u0434\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432\u0432\u043e\u0434\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $n$ \u0438 $p$ ($0\\leq\\; n,\\;p \\;\\leq\\; 10000$). \u0418\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e $p$ \u2013 \u043f\u0440\u043e\u0441\u0442\u043e\u0435.<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 $n$ \u0438 $p$ \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043d\u0430\u0438\u0431\u043e\u043b\u044c\u0448\u0435\u0435 \u0446\u0435\u043b\u043e\u0435 $k$, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e $D_n$ \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 $p^k$.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table style=\"width: 293px\">\n<tbody>\n<tr>\n<td style=\"width: 129.467px;text-align: center\">\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<td style=\"width: 147.533px;text-align: center\">\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 129.467px\">1 5<br \/>\n3 2<br \/>\n4 2<br \/>\n4 3<br \/>\n10000 3<\/td>\n<td style=\"width: 147.533px\">0<br \/>\n2<br \/>\n5<br \/>\n2<br \/>\n24962375<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 129.467px\">18 2<br \/>\n465 1009<br \/>\n9998 9221<br \/>\n548 11<\/td>\n<td style=\"width: 147.533px\">134<br \/>\n0<br \/>\n778<br \/>\n14412<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 129.467px\">1093 1093<br \/>\n1103 1723<br \/>\n3931 617<br \/>\n4868 6113<br \/>\n9534 71<\/td>\n<td style=\"width: 147.533px\">1<br \/>\n0<br \/>\n10635<br \/>\n0<br \/>\n639989<\/td>\n<\/tr>\n<tr>\n<td style=\"width: 129.467px\">617 17<br \/>\n42 11<br \/>\n0 5<\/td>\n<td style=\"width: 147.533px\">11295<br \/>\n63<br \/>\n0<\/td>\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 \" title=\"e-olymp 97. \u0427\u0438\u0441\u043b\u0430 \u0411\u0435\u043b\u043b\u0430\">import java.util.Scanner;\r\npublic class Main {\r\n \tpublic static void main (String[] args) {\r\n   \t\tScanner scanner = new Scanner(System.in);\r\n   \t\tint n, p;\r\n   \t\twhile(scanner.hasNextInt()) {\r\n   \t\t\tn = scanner.nextInt();\r\n   \t\t\tp = scanner.nextInt();\r\n   \t\t\tint k = 0;\r\n   \t\t\tfor (int i = 1; i  0) {\r\n   \t\t\t\t\tfact \/= p;\r\n   \t\t\t\t\tk += fact;\r\n   \t\t\t\t}\r\n   \t\t\t}\r\n   \t\t\tSystem.out.println(k);\r\n   \t\t}\r\n   \t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0427\u0438\u0441\u043b\u0430 \u0411\u0435\u043b\u043b\u0430 \u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c:<br \/>\n$$D_n = \\begin{vmatrix}<br \/>\nB_0&amp; B_1&amp; B_2&amp;\\ldots&amp; B_n\\\\<br \/>\nB_1&amp; B_2&amp; B_3&amp;\\ldots&amp; B_{n+1}\\\\<br \/>\n\\ldots&amp; \\ldots&amp; \\ldots&amp; \\ldots&amp; \\ldots\\\\<br \/>\nB_n&amp; B_{n+1}&amp; B_{n+2}&amp;\\ldots&amp; B_{2n}<br \/>\n\\end{vmatrix} = \\prod_{i=1}^n i!$$<br \/>\n\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u044d\u0442\u0438\u043c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438. \u041d\u0430\u0439\u0434\u0451\u043c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0447\u0438\u0441\u043b\u0430 $p$<br \/>\n\u0432 \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0435 \u043c\u043d\u043e\u0436\u0438\u0442\u0435\u043b\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0430\u043b\u043e\u0432. \u0421\u0443\u043c\u043c\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438 \u0431\u0443\u0434\u0435\u0442 \u044f\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0438\u0441\u043a\u043e\u043c\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $k$.<\/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\/97\" target=\"_blank\" rel=\"noopener\">e-olymp<\/a><br \/>\n\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 <a href=\"https:\/\/ideone.com\/fjTip7\" target=\"_blank\" rel=\"noopener\">ideone<\/a><br \/>\n\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/submissions\/4935117\" target=\"_blank\" rel=\"noopener\">e-olymp<\/a><br \/>\n\u0427\u0438\u0441\u043b\u043e \u0411\u0435\u043b\u043b\u0430 \u043d\u0430 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%A7%D0%B8%D1%81%D0%BB%D0%BE_%D0%91%D0%B5%D0%BB%D0%BB%D0%B0\" target=\"_blank\" rel=\"noopener\">wikipedia<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0427\u0438\u0441\u043b\u043e \u0411\u0435\u043b\u043b\u0430 $B_n$ \u0440\u0430\u0432\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0438\u0437 $n$ \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043f\u0435\u0440\u0435\u0441\u0435\u043a\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u043d\u0435\u043f\u0443\u0441\u0442\u044b\u0445 \u043f\u043e\u0434\u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, $B_3 = 5$, \u0442\u0430\u043a \u043a\u0430\u043a \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 $5$ \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0430\u0437\u0431\u0438\u0435\u043d\u0438\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 $\\lbrace a, b, c\\rbrace$: $\\lbrace\\lbrace a\\rbrace, \\lbrace b\\rbrace, \\lbrace c\\rbrace\\rbrace, \\lbrace\\lbrace a, b\\rbrace, \\lbrace c\\rbrace\\rbrace, \\lbrace\\lbrace a, c\\rbrace, \\lbrace b\\rbrace\\rbrace, \\lbrace\\lbrace a\\rbrace, \\lbrace b, c\\rbrace\\rbrace, \\lbrace\\lbrace a, &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4328\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":117,"featured_media":4335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[517,577,141,578,140,482],"jetpack_featured_media_url":"https:\/\/java.mazurok.com\/wp-content\/uploads\/Bell..jpg","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4328"}],"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\/117"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4328"}],"version-history":[{"count":7,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4328\/revisions"}],"predecessor-version":[{"id":4337,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4328\/revisions\/4337"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/media\/4335"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}