{"id":5005,"date":"2020-09-17T23:27:42","date_gmt":"2020-09-17T20:27:42","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=5005"},"modified":"2020-11-25T12:07:24","modified_gmt":"2020-11-25T09:07:24","slug":"e-olymp-4439-%d0%b2%d0%be%d0%b7%d0%b2%d0%b5%d0%b4%d0%b5%d0%bd%d0%b8%d0%b5-%d0%b2-%d1%81%d1%82%d0%b5%d0%bf%d0%b5%d0%bd%d1%8c","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=5005","title":{"rendered":"e-olymp 4439. \u0412\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 $a^b$.<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0414\u0432\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $a$ \u0438 $b$.<\/p>\n<h2>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 $a^b$, \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0447\u0442\u043e \u043e\u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442 $10^{18}$.<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table style=\"height: 102px\" width=\"385\">\n<tbody>\n<tr>\n<td><span class=\"hljs-tag\">\u2116<\/span><\/td>\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>\u00a01<\/td>\n<td>1 100<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>\u00a02<\/td>\n<td>2 10<\/td>\n<td>1024<\/td>\n<\/tr>\n<tr>\n<td>\u00a03<\/td>\n<td>3 7<\/td>\n<td>2187<\/td>\n<\/tr>\n<tr>\n<td>\u00a04<\/td>\n<td>8 9<\/td>\n<td>134217728<\/td>\n<\/tr>\n<tr>\n<td>\u00a05<\/td>\n<td>10 10<\/td>\n<td>10000000000<\/td>\n<\/tr>\n<tr>\n<td>\u00a06<\/td>\n<td>100 9<\/td>\n<td>1000000000000000000<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434<\/h1>\n<pre class=\"lang:java decode:true \">class Main{\r\n  public static long pow(long a, long b){\r\n    if(b == 0){ \r\n      return 1; \r\n    } \r\n    if(b % 2 == 0){ \r\n      return pow(a * a, b \/ 2); \r\n    } \r\n    return a * pow(a, b - 1);\r\n  }\r\n  public static void main (String[] args){\r\n    java.util.Scanner in = new java.util.Scanner(System.in);\r\n    long a = in.nextLong(), b = in.nextLong();\r\n    System.out.println(pow(a,b));\r\n  }\r\n}<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h1>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e &#171;pow()&#187;, \u0437\u0430\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 $a$ \u0438 \u0447\u0451\u0442\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 $b$ \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e\u0435 \u0442\u043e\u0436\u0434\u0435\u0441\u0442\u0432\u043e (\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0438\u0437 \u0430\u0441\u0441\u043e\u0446\u0438\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f):<br \/>\n$$a^b = \\left(a^2\\right)^{\\frac{b}{2}}= \\left(a\\cdot a\\right)^{\\frac{b}{2}}$$<br \/>\n\u041e\u043d\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c. \u0414\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u0434\u043b\u044f \u0447\u0451\u0442\u043d\u043e\u0433\u043e $b$ \u043c\u044b \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0438, \u043a\u0430\u043a, \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0432 \u0432\u0441\u0435\u0433\u043e \u043e\u0434\u043d\u0443 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u043c\u043e\u0436\u043d\u043e \u0441\u0432\u0435\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0447\u0443 \u043a \u0432\u0434\u0432\u043e\u0435 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438.<br \/>\n\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043f\u043e\u043d\u044f\u0442\u044c, \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0442\u0435\u043f\u0435\u043d\u044c b \u043d\u0435\u0447\u0451\u0442\u043d\u0430. \u0417\u0434\u0435\u0441\u044c \u043c\u044b \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u043f\u0435\u0440\u0435\u0439\u0434\u0451\u043c \u043a \u0441\u0442\u0435\u043f\u0435\u043d\u0438 b-1, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u0447\u0451\u0442\u043d\u043e\u0439:<br \/>\n$$a^b = a^{b-1} \\cdot a$$<br \/>\n\u0418\u0442\u0430\u043a, \u043c\u044b \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0430\u0448\u043b\u0438 \u0440\u0435\u043a\u0443\u0440\u0440\u0435\u043d\u0442\u043d\u0443\u044e \u0444\u043e\u0440\u043c\u0443\u043b\u0443: \u043e\u0442 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 $b$ \u043c\u044b \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c, \u0435\u0441\u043b\u0438 \u043e\u043d\u0430 \u0447\u0451\u0442\u043d\u0430, \u043a $\\frac{b}{2}$, \u0430 \u0438\u043d\u0430\u0447\u0435 \u2014 \u043a $b-1$.<\/p>\n<h1>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435<\/h1>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u044f\u043c\u043e\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 $b$ \u0440\u0430\u0437 \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 $b$-\u044e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e, \u0438\u0437-\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0439. \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c &#8212; \u044d\u0442\u043e\u00a0\u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u044b\u0439 \u0434\u043b\u044f \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f\u00a0\u0447\u0438\u0441\u043b\u0430 \u0432 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u0443\u044e\u00a0\u0441\u0442\u0435\u043f\u0435\u043d\u044c\u00a0\u0437\u0430 \u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0439, \u0447\u0435\u043c \u044d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438\u00a0\u0441\u0442\u0435\u043f\u0435\u043d\u0438.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\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\/4439\">e-olymp<\/a><br \/>\n\u041a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/ideone.com\/E9xZe4\">Ideone<\/a><br \/>\n\u0417\u0430\u0441\u0447\u0438\u0442\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/submissions\/7341417\">e-olymp<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 $a^b$. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0414\u0432\u0430 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430 $a$ \u0438 $b$. \u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 $a^b$, \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0447\u0442\u043e \u043e\u043d\u043e \u043d\u0435 \u043f\u0440\u0435\u0432\u043e\u0441\u0445\u043e\u0434\u0438\u0442 $10^{18}$. \u0422\u0435\u0441\u0442\u044b \u2116 \u0412\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415 \u0412\u042b\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415 \u00a01 1 100 1 \u00a02 2 10 1024 \u00a03 3 7 2187 \u00a04 8 9 134217728 \u00a05 10 10 10000000000 \u00a06 100 9 1000000000000000000 \u041a\u043e\u0434 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=5005\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":177,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6],"tags":[216,41,242,201,75],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5005"}],"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\/177"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5005"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5005\/revisions"}],"predecessor-version":[{"id":5165,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5005\/revisions\/5165"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}