{"id":4918,"date":"2019-03-31T13:39:16","date_gmt":"2019-03-31T10:39:16","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4918"},"modified":"2019-04-11T00:43:54","modified_gmt":"2019-04-10T21:43:54","slug":"4918","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4918","title":{"rendered":"e-olymp 2814. \u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0432\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<div id=\"attachment_27894\" style=\"width: 310px\" class=\"wp-caption alignright\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-27894\" src=\"http:\/\/cpp.mazurok.com\/wp-content\/uploads\/2018\/07\/Ligroin1-300x210.png\" alt=\"\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c\" width=\"300\" height=\"210\" class=\"size-medium wp-image-27894\" \/><p id=\"caption-attachment-27894\" class=\"wp-caption-text\">\u0411\u044b\u0441\u0442\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c<\/p><\/div>\u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f $x^{n}$ \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c $x$ \u0438 $n$, \u0433\u0434\u0435 $n$ &#8212; \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e.<br \/>\n\u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c $x^{16}$. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 $x$ \u0438 15 \u0440\u0430\u0437 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 $x$. \u041d\u043e \u0442\u043e\u0442 \u0436\u0435 \u043e\u0442\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0437\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f $x^{2}$, $x^{4}$, $x^{8}$, $x^{16}$.<br \/>\n\u042d\u0442\u0430 \u0436\u0435 \u0438\u0434\u0435\u044f, \u0432 \u0446\u0435\u043b\u043e\u043c, \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430 \u043a \u043b\u044e\u0431\u043e\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e $n$ \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0417\u0430\u043f\u0438\u0448\u0435\u043c $n$ \u0432 \u0432\u0438\u0434\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0441\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f (\u0443\u0431\u0438\u0440\u0430\u044f \u043d\u0443\u043b\u0438 \u0441\u043b\u0435\u0432\u0430). \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u043a\u0430\u0436\u0434\u0443\u044e &#171;1&#187; \u043f\u0430\u0440\u043e\u0439 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 SX, \u0430 \u043a\u0430\u0436\u0434\u044b\u0439 &#171;0&#187; &#8212; \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c S \u0438 \u0432\u044b\u0447\u0435\u0440\u043a\u043d\u0435\u043c \u043a\u0440\u0430\u0439\u043d\u044e\u044e \u0441\u043b\u0435\u0432\u0430 \u043f\u0430\u0440\u0443 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 SX. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f $x^{n}$, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c &#171;S&#187; \u0442\u0440\u0430\u043a\u0442\u0443\u0435\u0442\u0441\u044f \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442, \u0430 &#171;X&#187; &#8212; \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 $x$. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, $n = 23$ \u0438\u043c\u0435\u0435\u0442 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 $10111$. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c SXSSXSXSX, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0443\u044e \u043f\u0430\u0440\u0443 SX \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 SSXSXSX. \u042d\u0442\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0433\u043b\u0430\u0441\u0438\u0442, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e &#171;\u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442, \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442, \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 $x$, \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442, \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 $x$, \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u0438 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043d\u0430 $x$&#187;, \u0442.\u0435. \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f $x^{2}$, $x^{4}$, $x^{5}$, $x^{10}$, $x^{11}$, $x^{22}$, $x^{23}$.<\/p>\n<p>\u0412\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e n \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 $x$ \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c $x^{n}$<\/p>\n<h2>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h2>\n<p>\u041e\u0434\u043d\u043e \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e $n$, \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0435\u0435 $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\u0434\u0438\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0447\u0438\u0441\u043b\u0430 $x$ \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c $n$ \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f $x^{n}$.<\/p>\n<h2>\u0422\u0435\u0441\u0442\u044b<\/h2>\n<table>\n<tbody>\n<tr>\n<th>#<\/th>\n<th>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<th>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/th>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>23<\/td>\n<td>SSXSXSX<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>1<\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>16<\/td>\n<td>SSSS<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>1000000<\/td>\n<td>SXSXSXSSXSSSSSXSSSXSSSSSS<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>2018<\/td>\n<td>SXSXSXSXSXSSSSXS<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\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\tlong n, k = 0, c = 0;\r\n\t\tScanner S = new Scanner (System.in);\r\n\t\tn = S.nextLong();\r\n\t\twhile (n &gt; 1){\r\n\t\t\tlong bit = n &amp; 1;\r\n\t\t\tn &gt;&gt;= 1;\r\n\t\t\tk &lt;&lt;= 1;\r\n\t\t\tk |= bit;\r\n\t\t\tc += 1;\r\n\t\t}\r\n\t\twhile (c != 0) {\r\n\t\t\tlong bit = k &amp; 1;\r\n\t\t\tk &gt;&gt;= 1;\r\n\t\t\tif (bit == 0) System.out.print(\"S\");\r\n\t\t\telse System.out.print(\"SX\");\r\n\t\t\tc -= 1;\r\n\t\t}\r\n    }\r\n}<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h1>\n<div>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430  <span class=\"lang:c++ decode:true  crayon-inline \">while<\/span>  \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $k$ \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u043a\u043e\u0434 \u0447\u0438\u0441\u043b\u0430 $n$. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $c$ \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043a\u0430\u043a \u0441\u0447\u0451\u0442\u0447\u0438\u043a \u043a\u043e\u043b-\u0432\u0430 \u0431\u0438\u0442 \u0432 $n$. \u0412\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0446\u0438\u043a\u043b\u0435 <span class=\"lang:c++ decode:true  crayon-inline \">while<\/span> \u0432\u044b\u0432\u043e\u0434\u0438\u043c S \u0438\u043b\u0438 SX \u0435\u0441\u043b\u0438 \u043f\u0440\u0430\u0432\u044b\u0439 \u0431\u0438\u0442 $0$ \u0438\u043b\u0438 $1$ \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0442\u0435\u0440\u044f\u044f \u043f\u0440\u0438 \u044d\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044e\u044e $1$ \u043a\u0430\u043a \u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0438.<\/div>\n<p>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/2814\" target=\"_blank\" rel=\"noopener noreferrer\">e-olymp<\/a><br \/>\n\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f &#8212; <a href=\"https:\/\/ideone.com\/x05Edv\" target=\"_blank\" rel=\"noopener noreferrer\">ideone<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f $x^{n}$ \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c $x$ \u0438 $n$, \u0433\u0434\u0435 $n$ &#8212; \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u041f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c $x^{16}$. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 $x$ \u0438 15 \u0440\u0430\u0437 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u0435\u0433\u043e \u043d\u0430 $x$. \u041d\u043e \u0442\u043e\u0442 \u0436\u0435 \u043e\u0442\u0432\u0435\u0442 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u0437\u0430 \u0447\u0435\u0442\u044b\u0440\u0435 \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0432\u043e\u0437\u0432\u0435\u0441\u0442\u0438 \u0432 \u043a\u0432\u0430\u0434\u0440\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4918\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":113,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[685,534,273,686],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4918"}],"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\/113"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4918"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4918\/revisions"}],"predecessor-version":[{"id":4923,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4918\/revisions\/4923"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4918"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4918"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4918"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}