{"id":5349,"date":"2020-12-03T22:23:22","date_gmt":"2020-12-03T19:23:22","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=5349"},"modified":"2020-12-06T15:47:04","modified_gmt":"2020-12-06T12:47:04","slug":"e-olymp-9407-%d1%81%d0%bb%d0%b8%d1%8f%d0%bd%d0%b8%d0%b5-%d1%81%d1%82%d1%80%d0%be%d0%ba","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=5349","title":{"rendered":"e-olymp 9407. \u0421\u043b\u0438\u044f\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u0418\u043c\u0435\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 $A$ \u0438 $B$.<\/p>\n<p>\u0412\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 $C$, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438 $A$ \u0438 $B$ \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0439 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0442\u0430\u043a\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>\u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0434\u0443\u0449\u0430\u044f \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 $kbtu$ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 $kbtu open$, \u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0430 $fall$ \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f.<\/p>\n<h1>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 $A$ $(1 \\leqslant |A| \\leqslant 10^5)$.<\/p>\n<p>\u0412\u0442\u043e\u0440\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u0440\u043e\u043a\u0443 $B$ $(1 \\leqslant |B| \\leqslant 10^5)$.<\/p>\n<p>\u0413\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043e\u0431\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u043d\u044b\u0435 \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u0438\u0435 \u0431\u0443\u043a\u0432\u044b.<\/p>\n<h1>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043e\u0434\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0443 $C$.<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table style=\"height: 200px\" width=\"400\">\n<tbody>\n<tr>\n<th>\u2116<\/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>compressing<br \/>\nsingle<\/td>\n<td>compressingle<\/td>\n<\/tr>\n<tr>\n<td>2.<\/td>\n<td>can<br \/>\nyou<\/td>\n<td>canyou<\/td>\n<\/tr>\n<tr>\n<td>3.<\/td>\n<td>compressiondoneright<br \/>\ndoner<\/td>\n<td>compressiondoneright<\/td>\n<\/tr>\n<tr>\n<td>4.<\/td>\n<td>details<br \/>\ntail<\/td>\n<td>details<\/td>\n<\/tr>\n<tr>\n<td>5.<\/td>\n<td>essential<br \/>\ncode<\/td>\n<td>essentialcode<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434<\/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{\r\n\tpublic static boolean check(StringBuilder a, StringBuilder b) {\r\n\t\tif(a.length()==b.length()) {\r\n\t\t\tfor(int i = 0; i &lt; a.length(); i++) {\r\n\t\t\t\tif(a.charAt(i) != b.charAt(i)) return false;\r\n\t\t\t}\r\n\t\t}\r\n\treturn true;\r\n\t}\r\n \r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tint n, m, z;\r\n\t\tStringBuilder a = new StringBuilder();\r\n\t\tStringBuilder b = new StringBuilder();\r\n\t\tStringBuilder c = new StringBuilder();\r\n\t\tScanner in = new Scanner(System.in);\r\n    \ta.append( in.nextLine());\r\n    \tb.append( in.nextLine());\r\n    \tStringBuilder d = new StringBuilder(b);\r\n    \tn = b.length();\r\n    \tm = a.length();\r\n    \tc = new StringBuilder(a.substring(m - n, m));\r\n    \tif(a.toString().contains(b.toString()) != true) {\r\n        \tfor (int i = 1; i&lt;=n &amp;&amp; check(b,c) != true; i++) {\r\n            \tb.delete(n - i,m);\r\n            \tc.delete(0, 1);\r\n        \t}\r\n        \tz = c.length();\r\n        \td.delete(0,z);\r\n        \tSystem.out.print(a);\r\n        \tSystem.out.print(d);\r\n    \t}\r\n    \telse System.out.print(a);\r\n    \tSystem.exit(0);\r\n\t}\r\n}<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435<\/h1>\n<p>\u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 $C$, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 $A$ \u0438 $B$. \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438. <b>\u041f\u0435\u0440\u0432\u044b\u0439<\/b> \u2013 \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 $B$ \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 $A$, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 $A$. <b>\u0412\u0442\u043e\u0440\u043e\u0439<\/b> \u2013 \u0435\u0441\u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 $B$ \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 $A$ \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0438\u043b\u0438 \u043d\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432\u043e\u043e\u0431\u0449\u0435, \u0432\u044b\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 $A$ $+$ \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0441\u0442\u0440\u043e\u043a\u0438 $B$, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 $A$.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0441\u0442\u0440\u043e\u043a\u0430 $B$ \u0432 $A$, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>contains()<\/code>. \u0415\u0441\u043b\u0438 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u043c \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u0442\u043e \u0432\u044b\u0432\u043e\u0434\u0438\u043c $A$. \u0418\u043d\u0430\u0447\u0435, \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0446\u0438\u043a\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043a\u043e\u043d\u0446\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u0442\u043e\u0440\u043e\u0439, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0430\u0432\u043d\u044b. \u0417\u0430\u0442\u0435\u043c \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 $B$ \u0443\u0434\u0430\u043b\u044f\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0445\u043e\u0434\u044f\u0442 \u0432 \u0441\u0442\u0440\u043e\u043a\u0443 $A$, \u0438 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434 \u043f\u043e\u0434\u0430\u0451\u043c \u0441\u0442\u0440\u043e\u043a\u0443 $C$, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 $A$ \u0438 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 $B$.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<ul>\n<li>\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/9407\" target=\"_blank\" rel=\"noopener noreferrer\">e-olymp<\/a><\/li>\n<li>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043d\u0430 <a href=\"https:\/\/ideone.com\/A4D6bw\" target=\"_blank\" rel=\"noopener noreferrer\">ideone.com<\/a><\/li>\n<li>\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\/7776195\" target=\"_blank\" rel=\"noopener noreferrer\">e-olymp<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0418\u043c\u0435\u044e\u0442\u0441\u044f \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 $A$ \u0438 $B$. \u0412\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 &#8212; \u043d\u0430\u0439\u0442\u0438 \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 $C$, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438 $A$ \u0438 $B$ \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0442\u0447\u0430\u0439\u0448\u0435\u0439 \u0441\u0440\u0435\u0434\u0438 \u0432\u0441\u0435\u0445 \u0442\u0430\u043a\u0438\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a. \u041f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0434\u0443\u0449\u0430\u044f \u043f\u043e\u0434\u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u0442\u0440\u043e\u043a\u0430 $kbtu$ \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 $kbtu open$, \u043d\u043e \u0441\u0442\u0440\u043e\u043a\u0430 $fall$ \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f. &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=5349\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":150,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[752,275,632,753,754,151,755],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5349"}],"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\/150"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5349"}],"version-history":[{"count":4,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5349\/revisions"}],"predecessor-version":[{"id":5377,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/5349\/revisions\/5377"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}