{"id":332425,"date":"2022-04-26T09:00:35","date_gmt":"2022-04-26T09:00:35","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=332425"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=332425","title":{"rendered":"<span>\u0421\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435. \u0427\u0430\u0441\u0442\u044c 3 \u2014 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0420\u0430\u0431\u0438\u043d\u0430 \u2014 \u041a\u0430\u0440\u043f\u0430<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u044b\u0439 \u0438 \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u041e\u043d \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0435 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0430 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u0435\u043b. \u042f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u043e\u044f \u0446\u0435\u043b\u044c \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439.<br \/>  \u0418 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0435\u0441\u0442\u044c \u0447\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/658779\/\">\u0427\u0430\u0441\u0442\u044c 1 \u2014 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u041a\u043d\u0443\u0442\u0430 \u2014 \u041c\u043e\u0440\u0440\u0438\u0441\u0430 \u2014 \u041f\u0440\u0430\u0442\u0442\u0430<\/a><br \/>  <a href=\"https:\/\/habr.com\/ru\/post\/660767\/\">\u0427\u0430\u0441\u0442\u044c 2 \u2014 \u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0411\u043e\u0439\u0435\u0440\u0430 \u2014 \u041c\u0443\u0440\u0430<\/a><\/p>\n<p>  <\/p>\n<h2 id=\"ustroystvo-algoritma\">\u0423\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/h2>\n<p>  <\/p>\n<p>\u0412\u043e\u043e\u0431\u0449\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0445\u0435\u0448, \u043d\u043e \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u043b\u044e\u0431\u0430\u044f \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u0430\u044f \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u041d\u043e \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043f\u043e\u043b\u0438\u043d\u043e\u043c\u0438\u0430\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<p>  <\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0439: \u0431\u0435\u0440\u0435\u043c \u0445\u0435\u0448 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430, \u0431\u0435\u0440\u0435\u043c \u0445\u0435\u0448 \u043a\u0443\u0441\u043a\u0430 \u0442\u0435\u043a\u0441\u0442\u0430 \u0440\u0430\u0432\u043d\u043e\u0433\u043e \u043f\u043e \u0434\u043b\u0438\u043d\u0435, \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0445. \u0415\u0441\u043b\u0438 \u0440\u0430\u0432\u043d\u044b, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0445 \u043f\u043e\u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/3u\/9a\/ae\/3u9aae-py9_2jnbrgxts9-vqrpu.png\" data-src=\"https:\/\/habrastorage.org\/webt\/3u\/9a\/ae\/3u9aae-py9_2jnbrgxts9-vqrpu.png\"\/><\/p>\n<p>  <\/p>\n<h3 id=\"chto-eto-vse-znachit\">\u0427\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0438\u0442<\/h3>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e.<\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0439 \u0430\u043b\u0444\u0430\u0432\u0438\u0442, \u0433\u0434\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f00\/beb\/437\/f00beb4379e6c5238cf3f2838c8c07ff.svg\" alt=\"$a = 0, b = 1$\" data-tex=\"inline\"\/>.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0445\u0435\u0448 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/166\/af0\/006\/166af00064e31cad8ababd808a09a5c1.svg\" alt=\"$H(P) = 1 * 2^4 + 0 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0 = 21$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0445\u0435\u0448 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/d98\/513\/007\/d98513007afb5ed43aa8127ff0abd88f.svg\" alt=\"$T[0, 4]$\" data-tex=\"inline\"\/>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/34b\/4c4\/c0f\/34b4c4c0f551ecaaf501ca47a403a789.svg\" alt=\"$H(T[0, 4]) = 0 * 2^4 + 0 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0 = 5$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u041e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0432\u0438\u0433\u0430\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0440\u0430\u0432\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0445\u0435\u0448 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/0de\/d1c\/dfc\/0ded1cdfcdbb593bbb6715fd2ab61451.svg\" alt=\"$T[1, 5]$\" data-tex=\"inline\"\/>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ace\/706\/87e\/ace70687eca927a6cd9d5b2de0091f7a.svg\" alt=\"$H(T[1, 5]) = (H(T[0, 4]) - 0 * 2^4) * 2 + 0 * 2^0 = 10$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u0425\u0435\u0448\u0438 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430 \u0441\u043d\u043e\u0432\u0430 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442, \u0437\u043d\u0430\u0447\u0438\u0442 \u0434\u0432\u0438\u0433\u0430\u0435\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0435\u0449\u0435 \u043d\u0430 \u0441\u0438\u043c\u0432\u043e\u043b \u043f\u0440\u0430\u0432\u0435\u0435.<\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0445\u0435\u0448 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/df0\/2a1\/a4f\/df02a1a4f88368877dfaf2193a29e257.svg\" alt=\"$T[2, 6]$\" data-tex=\"inline\"\/>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/350\/506\/399\/3505063990a9dd25960a756535c71497.svg\" alt=\"$H(T[2, 6]) = (H(T[1, 5]) - 0 * 2^4) * 2 + 1 * 2^0 = 21$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u0425\u0435\u0448\u0438 \u0441\u043e\u0432\u043f\u0430\u043b\u0438, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0447\u043d\u043e.<\/p>\n<p>  <\/p>\n<h3 id=\"raschet-hesha\">\u0420\u0430\u0441\u0447\u0435\u0442 \u0445\u0435\u0448\u0430<\/h3>\n<p>  <\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438, \u043c\u044b \u043f\u043e \u0444\u0430\u043a\u0442\u0443 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0445 \u0432 \u0447\u0438\u0441\u043b\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0447\u0438\u0442\u043b\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u044d\u0442\u043e \u0440\u0430\u0437\u0440\u044f\u0434, \u0435\u0433\u043e \u043a\u043e\u0434 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0440\u0430\u0437\u0440\u044f\u0434\u0430, \u0430 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435 (\u0432\u043e\u043e\u0431\u0449\u0435 \u044d\u0442\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0437\u0430 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u043b\u044e\u0431\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0435\u0434\u0438\u043d\u0438\u0446\u044b, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0431\u0443\u0434\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0442\u044c\u0441\u044f \u0447\u0430\u0449\u0435. \u0427\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043d\u0435 \u0443\u043f\u0435\u0440\u0435\u0442\u044c\u0441\u044f \u0432 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435<strong>\ud83d\ude42<\/strong>).<\/p>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0432\u0438\u0434\u0435 \u0440\u0430\u0441\u0447\u0435\u0442 \u0445\u0435\u0448\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/bed\/422\/a11\/bed422a119f847b667fd0b03847b1db0.svg\" alt=\"$H(P) = p[0] * x^{m-1} + p[1] * x^{m-2} + ... + p[m-1] * x^0$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3c8\/da9\/48a\/3c8da948a52085be728f76fe67e197d3.svg\" alt=\"$H(P)$\" data-tex=\"inline\"\/> \u2014 \u0445\u0435\u0448 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/4cc\/fd4\/32e\/4ccfd432ea4f2a64f3a5c8c7378517af.svg\" alt=\"$x$\" data-tex=\"inline\"\/> \u2014 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0445\u0435\u0448 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438. \u0412\u043e\u0437\u044c\u043c\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0443 <strong>Pattern<\/strong> \u0438 \u0434\u043b\u044f \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u043e\u0441\u0442\u0438 \u0437\u0430 <strong>x<\/strong> \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u044c \u0441\u0435\u043c\u0438\u0431\u0438\u0442\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b ASCII \u2014 <strong>128<\/strong>.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/acc\/718\/3d8\/acc7183d8965bc5d9a736b788b330268.svg\" alt=\"$H(Pattern) = 80 * 128^6 + 97 * 128^5 + 116 * 128^4 + 116 * 128^3 \\\\ + 101 * 128^2 + 114 * 128^1 + 110 * 128^0$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: <strong>355 207 998 962 030<\/strong><\/p>\n<p>  <\/p>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043c\u043d\u043e\u0433\u043e\u0432\u0430\u0442\u043e. \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0432 \u0434\u0432\u043e\u0438\u0447\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f 49 \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432, \u0430 \u0443 \u043d\u0430\u0441 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u0438\u043d\u043d\u043e\u0439 7 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438 \u0443\u0440\u0435\u0437\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430 ASCII. \u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0432\u043e\u0441\u044c\u043c\u0438\u0431\u0438\u0442\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0443\u0436\u0435 \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u0436\u0435 \u043d\u0430 64-\u0445 \u0431\u0438\u0442\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445. \u0422\u0430\u043a \u0447\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0433\u0443\u0442 <strong>\u0441\u0445\u0435\u043c\u0430 \u0413\u043e\u0440\u043d\u0435\u0440\u0430<\/strong> \u0438 <strong>\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430<\/strong>.<\/p>\n<p>  <\/p>\n<h3 id=\"shema-gornera\">\u0421\u0445\u0435\u043c\u0430 \u0413\u043e\u0440\u043d\u0435\u0440\u0430<\/h3>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/28d\/04b\/d11\/28d04bd11fa0a2f299bfab615c2ac707.svg\" alt=\"$H(P) = p[m-1] * x^{m-1} + p[m-2] * x^{m-2} + ... + p[0] * x^0 = \\\\ (...(p[m-1] * x + p[m-2]) * x + ... + p[1]) * x + p[0]$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u0415\u0435 \u0437\u0430\u0434\u0430\u0447\u0430 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f \u043e\u0442 \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0436\u043e\u0440\u043b\u0438\u0432\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0431\u0435\u0437 \u0441\u0445\u0435\u043c\u044b \u0413\u043e\u0440\u043d\u0435\u0440\u0430 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u043d\u0435\u0442 \u043c\u0435\u043d\u0435\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u044b\u043c. \u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0445\u0441\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<p>\u0414\u0430 \u0438 \u043d\u0438\u043a\u0430\u043a\u0430\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430 \u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043c\u043e\u0436\u0435\u0442, \u0435\u0441\u043b\u0438 \u0443 \u043d\u0430\u0441 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0434\u043b\u0438\u043d\u043e\u0439 128 ASCII-\u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u0432\u043e\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0438 \u0432 \u0441\u0442\u0435\u043f\u0435\u043d\u044c, \u0443 \u043d\u0430\u0441 \u0434\u043b\u044f \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u0432 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0447\u0438\u0441\u043b\u043e <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/cf1\/862\/739\/cf186273957a7382f98c27fac327ab6d.svg\" alt=\"$2^{1024}$\" data-tex=\"inline\"\/>, \u0430 \u044d\u0442\u043e, \u043a\u0430\u043a \u0432\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0435\u0442\u0435, \u043c\u043d\u043e\u0433\u043e.<\/p>\n<p>  <\/p>\n<h3 id=\"modulnaya-arifmetika\">\u041c\u043e\u0434\u0443\u043b\u044c\u043d\u0430\u044f \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0430<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0445\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0431\u0443\u0434\u0435\u043c \u0431\u0440\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430\u0448 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b39\/0a3\/899\/b390a389986cf6c4f1d9749dd3495fec.svg\" alt=\"$H(P) = (((...((p[m-1] * x + p[m-2])\\mod q) * x \\\\ + ... + p[1]) \\mod q) * x + p[0]) \\mod q$\" data-tex=\"display\"\/><\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0432\u0441\u0435\u0445 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0435<br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c0e\/f9f\/7b6\/c0ef9f7b62bf86417b44bd8f8d40e493.svg\" alt=\"$p_{max} * (x + 1)$\" data-tex=\"inline\"\/>.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d \u043d\u044e\u0430\u043d\u0441:<\/p>\n<p>  <\/p>\n<blockquote><p>\u041a\u043e\u0433\u0434\u0430 \u0442\u0435\u0431\u0435 \u0443\u0434\u0430\u0435\u0442\u0441\u044f \u0432\u043f\u0438\u0445\u043d\u0443\u0442\u044c \u043d\u0435\u0432\u043f\u0438\u0445\u0443\u0435\u043c\u043e\u0435, \u0442\u044b \u0437\u043b\u0438\u0448\u044c \u0431\u043e\u0433\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439<\/p><\/blockquote>\n<p>  <\/p>\n<h3 id=\"pobeg-ot-boga-kolliziy\">\u041f\u043e\u0431\u0435\u0433 \u043e\u0442 \u0431\u043e\u0433\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439<\/h3>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0437\u0430\u0431\u0443\u0440\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u0437\u044b\u0441\u043a\u0430\u043d\u0438\u044f \u043d\u0430 \u0442\u0435\u043c\u0443 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439 \u0432 \u043a\u043e\u043b\u044c\u0446\u0435\u0432\u044b\u0445 \u0445\u0435\u0448-\u0444\u0443\u043d\u043a\u0446\u0438\u044f\u0445, \u0442\u043e \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u0442\u0443\u0434\u0430 \u043d\u0435 \u0432\u044b\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u0415\u0441\u043b\u0438 \u043a\u0440\u0430\u0442\u043a\u043e, \u0442\u043e \u0447\u0438\u0441\u043b\u043e <strong>q<\/strong> \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u043c. \u0410 \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u0442\u043e \u0432\u043e\u0442:<\/p>\n<p>  <\/p>\n<h4 id=\"popodrobnee\">\u041f\u043e\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435<\/h4>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0442\u0435\u043a\u0441\u0442 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/3e4\/9fb\/584\/3e49fb58474f899dddcab78289ef7d69.svg\" alt=\"$t[0...n]$\" data-tex=\"inline\"\/> \u0434\u043b\u0438\u043d\u043e\u0439 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f01\/75a\/f31\/f0175af31bbb28b00d40cbf07d219e44.svg\" alt=\"$len = n + 1$\" data-tex=\"inline\"\/>. \u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u043e\u0437\u044c\u043c\u0435\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/c07\/a31\/113\/c07a3111335d7facc4ae7769133094bc.svg\" alt=\"$q > len^c$&#187; data-tex=&#187;inline&#187;\/>, \u0433\u0434\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/888\/670\/b81\/888670b8101985774255301905c18b10.svg\" alt=\"$c > 2$&#187; data-tex=&#187;inline&#187;\/>, \u0442\u043e \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u043c\u0435\u043d\u0435\u0435, \u0447\u0435\u043c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f03\/6cb\/b56\/f036cbb567061d5cd96c40612370a4f3.svg\" alt=\"$1\/n^{c - 2}$\" data-tex=\"inline\"\/><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0431\u0435\u0436\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u0439 \u0442\u044b\u0441\u044f\u0447\u0435 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0447\u0438\u0441\u0435\u043b \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/893\/167\/b25\/893167b251ad1246864d0ee39a2f0ecb.svg\" alt=\"$N(Q)$\" data-tex=\"inline\"\/>, \u0433\u0434\u0435 <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/9aa\/e08\/704\/9aae087046a60218262bab4a00522adc.svg\" alt=\"$N$\" data-tex=\"inline\"\/> \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/4f\/30\/il\/4f30il5dyztrwxa97yf0gzzajaa.png\" alt=\"\u0432\u043e\u0442\" data-src=\"https:\/\/habrastorage.org\/webt\/4f\/30\/il\/4f30il5dyztrwxa97yf0gzzajaa.png\"\/><\/p>\n<p>  <\/p>\n<p>\u0417\u0434\u0435\u0441\u044c \u044f \u043f\u0440\u043e\u0432\u0435\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 \u043e\u0442\u0440\u044b\u0432\u043a\u0435 \u043f\u0440\u043e \u0434\u0443\u0431 \u0438\u0437 \u0412\u043e\u0439\u043d\u044b \u0438 \u043c\u0438\u0440\u0430, \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u043b \u0441\u0442\u0440\u043e\u043a\u0443 <strong>\u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d<\/strong>. \u0414\u0430 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u0447\u0438\u0441\u043b\u0430 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0441\u0430\u043c\u044b\u0435 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0435, \u043d\u043e \u0437\u0430\u0442\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439. \u0418 \u043a\u0430\u043a \u044d\u0442\u043e \u043d\u0435 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u043e \u2014 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0431\u044b\u0447\u043d\u0443\u044e \u0430\u0441\u0438\u043c\u043f\u0442\u043e\u0442\u0443. \u041d\u0443 \u0438 \u043a\u0430\u043a \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u043e\u0441\u043b\u0435 7000 \u0441\u0430\u043c\u043e\u0435 \u0445\u0443\u0434\u0448\u0435\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u044d\u0442\u043e 1 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u044e. \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043d\u0435 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a\u043e\u0433\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u0432\u0441\u043f\u043b\u0435\u0441\u043a\u0430. \u041d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0441 2000 \u0441\u0430\u043c\u043e\u0435 \u0445\u0443\u0434\u0448\u0435\u0435, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u044b\u043b\u043e \u044d\u0442\u043e 4 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438 \u043d\u0430 \u0442\u0435\u043a\u0441\u0442 1671 \u0441\u0438\u043c\u0432\u043e\u043b\u0430.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0435 \u043b\u043e\u0433\u0438\u0447\u043d\u043e, \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0435 \u0447\u0438\u0441\u043b\u043e, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u044b \u0441\u043a\u0443\u043a\u043e\u0436\u0438\u0432\u0430\u0435\u043c \u0445\u0435\u0448, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0439. \u0412\u0435\u0434\u044c \u043a\u043e\u0433\u0434\u0430 \u043c\u044b \u0431\u0435\u0440\u0435\u043c \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u0447\u0438\u0441\u0435\u043b <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/b80\/560\/771\/b80560771af3db501904933da14f1207.svg\" alt=\"$[0; 2^{1024}]$\" data-tex=\"inline\"\/>, (\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u043e\u0439 \u0445\u0435\u0448 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0431\u0435\u0437 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u0439 \u0430\u0440\u0438\u0444\u043c\u0435\u0442\u0438\u043a\u0438), \u0438 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u0435\u0433\u043e \u0443\u0436\u0430\u0442\u044c \u0432 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/f05\/e30\/c3b\/f05e30c3b93c8328b91eeda7ebc0418e.svg\" alt=\"$[0, 2^{32}-1]$\" data-tex=\"inline\"\/>, \u0442\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0437\u0430 \u044d\u0442\u043e \u0447\u0435\u043c-\u0442\u043e \u0437\u0430\u043f\u043b\u0430\u0442\u0438\u0442\u044c. \u0418 \u0446\u0435\u043d\u0430 \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043b\u043b\u0438\u0437\u0438\u0438.<\/p>\n<p>  <\/p>\n<h2 id=\"kod-algoritma\">\u041a\u043e\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430<\/h2>\n<p>  <\/p>\n<pre><code class=\"javascript\">export function getSubstringRK(text: string, pattern: string): number[] {     const result = [];      const alphabetSize = 256;     const mod = 9973;      let patternHash = pattern.charCodeAt(0) % mod;     let textHash = text.charCodeAt(0) % mod;      let firstIndexHash = 1;      for(let i = 1; i &lt; pattern.length; i++)     {         patternHash *= alphabetSize;         patternHash += pattern.charCodeAt(i);         patternHash %= mod;          textHash *= alphabetSize;         textHash += text.charCodeAt(i);         textHash %= mod;          firstIndexHash *= alphabetSize;         firstIndexHash %= mod;     }      for (let i = 0; i &lt;= text.length - pattern.length; i++) {         if (patternHash === textHash &amp;&amp; compareText(text, i, pattern)) {             result.push(i);         }          if (i === text.length - pattern.length) break;          textHash -= (text.charCodeAt(i) * firstIndexHash) % mod;         textHash += mod;         textHash *= alphabetSize;         textHash += text.charCodeAt(i + pattern.length);         textHash %= mod;     }      return result; }  function compareText(text: string, index: number, pattern: string): boolean {     for (let i = 0; i &lt; pattern.length; i++) {         if (pattern[i] !== text[index + i]) {             return false;         }     }      return true; } <\/code><\/pre>\n<p>  <\/p>\n<h2 id=\"zamery-proizvoditelnosti\">\u0417\u0430\u043c\u0435\u0440\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438<\/h2>\n<p>  <\/p>\n<p>\u041a\u043e\u043d\u043a\u0443\u0440\u0441\u044b \u0432\u0441\u0435 \u0442\u0435 \u0436\u0435:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0425\u0443\u0434\u0448\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439.<\/li>\n<li>\u0421\u0442\u0440\u043e\u043a\u0430 \u0441 \u043c\u0430\u043b\u043e\u043c\u043e\u0449\u043d\u044b\u043c \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u043e\u043c.<\/li>\n<li>\u0420\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.<\/li>\n<\/ul>\n<p>  <\/p>\n<h3 id=\"oruschie-stroki\">\u041e\u0440\u0443\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438<\/h3>\n<p>  <\/p>\n<p>\u0417\u0430\u043c\u0435\u0440\u044b, \u0433\u0434\u0435 \u0438 \u0442\u0435\u043a\u0441\u0442 \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0431\u0443\u043a\u0432\u044b &#171;\u0430&#187;.<\/p>\n<p>  <\/p>\n<p>\u0422\u0435\u043a\u0441\u0442: \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 1024 \u0441\u0438\u043c\u0432\u043e\u043b\u0430<br \/>  \u041e\u0431\u0440\u0430\u0437\u0435\u0446: \u0441\u0442\u0440\u043e\u043a\u0430 \u0434\u043b\u0438\u043d\u043d\u043e\u0439 32 \u0441\u0438\u043c\u0432\u043e\u043b\u0430<\/p>\n<p>  <\/p>\n<h4 id=\"opssec\">Ops\/sec<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">getSubstringNaive x 9,141 getSubstringKMP x 84,419 getSubstringNotSoNaive x 9,587 getSubstringBMBadCharacter x 9,103 getSubstringRK x 9,975<\/code><\/pre>\n<p>  <\/p>\n<h4 id=\"kolichestvo-sravneniy\">\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">getSubstringNaive : 31,776 getSubstringKMP : 2,047 getSubstringNotSoNaive : 31,776     getSubstringBMBadCharacter : 31,776 getSubstringRK : 32,769 <\/code><\/pre>\n<p>  <\/p>\n<p>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0420\u0430\u0431\u0438\u043d\u0430-\u041a\u0430\u0440\u043f\u0430 \u043f\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0445\u0443\u0434\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ac3\/7d5\/1db\/ac37d51db7de582ffae9bafb87b6f5ec.svg\" alt=\"$O(n * m)$\" data-tex=\"inline\"\/>, \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0438\u0447\u0435\u043c \u0441\u0438\u043b\u044c\u043d\u043e \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u0435\u043b\u0430\u0435\u0442 \u0431\u043e\u043b\u044c\u0448\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439. \u0412\u0435\u0434\u044c \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0441\u0432\u0435\u0440\u044f\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0432\u0435\u0440\u0438\u0442\u044c \u0445\u0435\u0448. \u0422\u0430\u043a \u0447\u0442\u043e \u0437\u0434\u0435\u0441\u044c \u043d\u0430\u0448 \u043f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u044b\u0439 \u0430\u0443\u0442\u0441\u0430\u0439\u0434\u0435\u0440.<\/p>\n<p>  <\/p>\n<h3 id=\"psevdo-dnk\">\u041f\u0441\u0435\u0432\u0434\u043e \u0414\u041d\u041a<\/h3>\n<p>  <\/p>\n<p>\u0421\u0442\u0440\u043e\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u0449\u0430\u044f \u0438\u0437 1024 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 [TGAC]. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u0421\u0442\u0440\u043e\u043a\u0430 \u0414\u041d\u041a<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>GTAGTGTGTCTACGTCTTTCTTTGACAGTACCGCGTAATTTGCAGTGCTATAAATCATCTCTAACGCTGGCTGTGCACCGCCACCGTAGTGTGTCTACGTCTTTCTTTGACAGTACCGCGTAATTTGCAGTGCTATAAATCATCTCTAACGCTGGCTGTGCACCGCCACCCCAGCGGGAAGCCCATTTTTCCACTACCTCTGTTCCTGGTATAGTGCACTATATCGCCCGTAACCGATGTCTCGCCAAGATTTTGGCAACTTCCCGAGCAATCAGGTGGAGTCAGACCGATAGCTCTAATGGTTTACGTGAATGCATGGCGCCTATAGCTATGGGCAGAAACCAGCGGGAAGCCCATTTTTCCACTACCTCTGTTCCTGGTATAGTGCACTATATCGCCCGGTAGTGTGTCTACGTCTTTCTTTGACAGTACCGCGTAATTTGCAGTGCTATAAATCATCTCTAACGCTGGCTGTGCACCGCCACCCCAGCGGGAAGCCCATTTTTCCACTACCTCTGTTCCTGGTATAGTGCACTATATCGCCCGTAACCGATGTCTCGCCAAGATTTTGGCAACTTCCCGAGCAATCAGGTGGAGTCAGACCGATAGCTCTAATGGTTTACGTGAATGCATGGCGCCTATAGCTATGGGCAGAAATAACCGATGTCTCGCCAAGATTTTGGCAACGTAGTGTGTCTACGTCTTTCTTTGACAGTACCGCGTAATTTGCAGTGCTATAAATCATCTCTAACGCTGGCTGTGCACCGCCACCCCAGCGGGAAGCCCATTTTTCCACTACCTCTGTTCCTGGTATAGTGCACTATATCGCCCGTAACCGATGTCTCGCCAAGATTTTGGCAACTTCCCGAGCAATCAGGTGGAGTCAGACCGATAGCTCTAATGGTTTACGTGAATGCATGGCGCCTATAGCTATGGGCAGAAATTCCCGAGCAATCAGGTGGAGTCAGACCGATAGCTCTAATGGTTTACGTGAATGCATGGCGCCTATAGCTATGGGCAGAAA<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0437\u0435\u0446: <code>GTAGTGTGTCTACGTCTTTCTTTGACAGTACCGCGTA<\/code>. (37 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432)<\/p>\n<p>  <\/p>\n<h4 id=\"opssec-1\">Ops\/sec<\/h4>\n<p>  <\/p>\n<p>getSubstringNaive x 6,349<br \/>  getSubstringKMP x 156,780<br \/>  getSubstringNotSoNaive x 189,694<br \/>  getSubstringBMBadCharacter x 199,476<br \/>  getSubstringRK x 229,361<\/p>\n<p>  <\/p>\n<h4 id=\"kolichestvo-sravneniy-1\">\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439<\/h4>\n<p>  <\/p>\n<pre><code class=\"plaintext\">getSubstringNaive : 36,556 getSubstringKMP : 1,422 getSubstringNotSoNaive : 1,434     getSubstringBMBadCharacter : 925 getSubstringRK : 1,136<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0420\u0430\u0431\u0438\u043d\u0430-\u041a\u0430\u0440\u043f\u0430 \u043d\u0430 \u0432\u0442\u043e\u0440\u043e\u043c \u043c\u0435\u0441\u0442\u0435, \u043f\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439, \u043e\u043d \u043e\u043f\u0435\u0440\u0435\u0436\u0430\u0435\u0442 \u0411\u043e\u0439\u0435\u0440\u0430-\u041c\u0443\u0440\u0430. \u041d\u0443 \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e \u0411\u041c \u0441 \u044d\u0432\u0440\u0438\u0441\u0442\u0438\u043a\u043e\u0439 \u043f\u043b\u043e\u0445\u043e\u0433\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u0430 \u043d\u0435 \u0442\u0430\u043a \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u0435\u043d \u043d\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a\u0430\u0445.<\/p>\n<p>  <\/p>\n<h3 id=\"voyna-i-mir\">\u0412\u043e\u0439\u043d\u0430 \u0438 \u043c\u0438\u0440<\/h3>\n<p>  <\/p>\n<p>\u0422\u0435\u043a\u0441\u0442:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\" role=\"button\" tabindex=\"0\">                         <b class=\"spoiler_title\">\u041e\u0442\u0440\u044b\u0432\u043e\u043a \u043f\u0440\u043e \u0434\u0443\u0431<\/b>                         <\/p>\n<div class=\"spoiler_text\">\n<p>\u041d\u0430 \u043a\u0440\u0430\u044e \u0434\u043e\u0440\u043e\u0433\u0438 \u0441\u0442\u043e\u044f\u043b \u0434\u0443\u0431. \u0412\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437 \u0441\u0442\u0430\u0440\u0448\u0435 \u0431\u0435\u0440\u0435\u0437, \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0432\u0448\u0438\u0445 \u043b\u0435\u0441, \u043e\u043d \u0431\u044b\u043b \u0432 \u0434\u0435\u0441\u044f\u0442\u044c \u0440\u0430\u0437 \u0442\u043e\u043b\u0449\u0435, \u0438 \u0432 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430 \u0432\u044b\u0448\u0435 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0435\u0440\u0435\u0437\u044b. \u042d\u0442\u043e \u0431\u044b\u043b \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u0439, \u0432 \u0434\u0432\u0430 \u043e\u0431\u0445\u0432\u0430\u0442\u0430 \u0434\u0443\u0431, \u0441 \u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d\u044b\u043c\u0438, \u0434\u0430\u0432\u043d\u043e, \u0432\u0438\u0434\u043d\u043e, \u0441\u0443\u043a\u0430\u043c\u0438 \u0438 \u0441 \u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d\u043e\u0439 \u043a\u043e\u0440\u043e\u0439, \u0437\u0430\u0440\u043e\u0441\u0448\u0435\u0439 \u0441\u0442\u0430\u0440\u044b\u043c\u0438 \u0431\u043e\u043b\u044f\u0447\u043a\u0430\u043c\u0438. \u0421 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u043c\u0438 \u0441\u0432\u043e\u0438\u043c\u0438 \u043d\u0435\u0443\u043a\u043b\u044e\u0436\u0435, \u043d\u0435\u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u043e \u0440\u0430\u0441\u0442\u043e\u043f\u044b\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u043a\u043e\u0440\u044f\u0432\u044b\u043c\u0438 \u0440\u0443\u043a\u0430\u043c\u0438 \u0438 \u043f\u0430\u043b\u044c\u0446\u0430\u043c\u0438, \u043e\u043d \u0441\u0442\u0430\u0440\u044b\u043c, \u0441\u0435\u0440\u0434\u0438\u0442\u044b\u043c \u0438 \u043f\u0440\u0435\u0437\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0443\u0440\u043e\u0434\u043e\u043c \u0441\u0442\u043e\u044f\u043b \u043c\u0435\u0436\u0434\u0443 \u0443\u043b\u044b\u0431\u0430\u044e\u0449\u0438\u043c\u0438\u0441\u044f \u0431\u0435\u0440\u0435\u0437\u0430\u043c\u0438. \u0422\u043e\u043b\u044c\u043a\u043e \u043e\u043d \u043e\u0434\u0438\u043d \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0447\u0438\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0431\u0430\u044f\u043d\u0438\u044e \u0432\u0435\u0441\u043d\u044b \u0438 \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0432\u0438\u0434\u0435\u0442\u044c \u043d\u0438 \u0432\u0435\u0441\u043d\u044b, \u043d\u0438 \u0441\u043e\u043b\u043d\u0446\u0430.<\/p>\n<p>  <\/p>\n<p>\u00ab\u0412\u0435\u0441\u043d\u0430, \u0438 \u043b\u044e\u0431\u043e\u0432\u044c, \u0438 \u0441\u0447\u0430\u0441\u0442\u0438\u0435! \u2014 \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u043b \u044d\u0442\u043e\u0442 \u0434\u0443\u0431. \u2014 \u0418 \u043a\u0430\u043a \u043d\u0435 \u043d\u0430\u0434\u043e\u0435\u0441\u0442 \u0432\u0430\u043c \u0432\u0441\u0435 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0433\u043b\u0443\u043f\u044b\u0439 \u0431\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u043c\u0430\u043d! \u0412\u0441\u0435 \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435, \u0438 \u0432\u0441\u0435 \u043e\u0431\u043c\u0430\u043d! \u041d\u0435\u0442 \u043d\u0438 \u0432\u0435\u0441\u043d\u044b, \u043d\u0438 \u0441\u043e\u043b\u043d\u0446\u0430, \u043d\u0438 \u0441\u0447\u0430\u0441\u0442\u044c\u044f. \u0412\u043e\u043d \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435, \u0441\u0438\u0434\u044f\u0442 \u0437\u0430\u0434\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0440\u0442\u0432\u044b\u0435 \u0435\u043b\u0438, \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u0438\u0435, \u0438 \u0432\u043e\u043d \u0438 \u044f \u0440\u0430\u0441\u0442\u043e\u043f\u044b\u0440\u0438\u043b \u0441\u0432\u043e\u0438 \u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d\u044b\u0435, \u043e\u0431\u043e\u0434\u0440\u0430\u043d\u043d\u044b\u0435 \u043f\u0430\u043b\u044c\u0446\u044b, \u0433\u0434\u0435 \u043d\u0438 \u0432\u044b\u0440\u043e\u0441\u043b\u0438 \u043e\u043d\u0438 \u2014 \u0438\u0437 \u0441\u043f\u0438\u043d\u044b, \u0438\u0437 \u0431\u043e\u043a\u043e\u0432. \u041a\u0430\u043a \u0432\u044b\u0440\u043e\u0441\u043b\u0438 \u2014 \u0442\u0430\u043a \u0438 \u0441\u0442\u043e\u044e, \u0438 \u043d\u0435 \u0432\u0435\u0440\u044e \u0432\u0430\u0448\u0438\u043c \u043d\u0430\u0434\u0435\u0436\u0434\u0430\u043c \u0438 \u043e\u0431\u043c\u0430\u043d\u0430\u043c\u00bb .<\/p>\n<p>  <\/p>\n<p>\u041a\u043d\u044f\u0437\u044c \u0410\u043d\u0434\u0440\u0435\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043e\u0433\u043b\u044f\u043d\u0443\u043b\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0434\u0443\u0431, \u043f\u0440\u043e\u0435\u0437\u0436\u0430\u044f \u043f\u043e \u043b\u0435\u0441\u0443, \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u043e\u043d \u0447\u0435\u0433\u043e-\u0442\u043e \u0436\u0434\u0430\u043b \u043e\u0442 \u043d\u0435\u0433\u043e. \u0426\u0432\u0435\u0442\u044b \u0438 \u0442\u0440\u0430\u0432\u0430 \u0431\u044b\u043b\u0438 \u0438 \u043f\u043e\u0434 \u0434\u0443\u0431\u043e\u043c, \u043d\u043e \u043e\u043d \u0432\u0441\u0435 \u0442\u0430\u043a \u0436\u0435, \u0445\u043c\u0443\u0440\u044f\u0441\u044c, \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e, \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e \u0438 \u0443\u043f\u043e\u0440\u043d\u043e, \u0441\u0442\u043e\u044f\u043b \u043f\u043e\u0441\u0440\u0435\u0434\u0438 \u0438\u0445.<\/p>\n<p>  <\/p>\n<p>\u00ab\u0414\u0430, \u043e\u043d \u043f\u0440\u0430\u0432, \u0442\u044b\u0441\u044f\u0447\u0443 \u0440\u0430\u0437 \u043f\u0440\u0430\u0432 \u044d\u0442\u043e\u0442 \u0434\u0443\u0431, \u2014 \u0434\u0443\u043c\u0430\u043b \u043a\u043d\u044f\u0437\u044c \u0410\u043d\u0434\u0440\u0435\u0439, \u2014 \u043f\u0443\u0441\u043a\u0430\u0439 \u0434\u0440\u0443\u0433\u0438\u0435, \u043c\u043e\u043b\u043e\u0434\u044b\u0435, \u0432\u043d\u043e\u0432\u044c \u043f\u043e\u0434\u0434\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u043e\u0431\u043c\u0430\u043d, \u0430 \u043c\u044b \u0437\u043d\u0430\u0435\u043c \u0436\u0438\u0437\u043d\u044c, \u2014 \u043d\u0430\u0448\u0430 \u0436\u0438\u0437\u043d\u044c \u043a\u043e\u043d\u0447\u0435\u043d\u0430! \u00bb \u0426\u0435\u043b\u044b\u0439 \u043d\u043e\u0432\u044b\u0439 \u0440\u044f\u0434 \u043c\u044b\u0441\u043b\u0435\u0439 \u0431\u0435\u0437\u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0445, \u043d\u043e \u0433\u0440\u0443\u0441\u0442\u043d\u043e-\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0445 \u0432 \u0441\u0432\u044f\u0437\u0438 \u0441 \u044d\u0442\u0438\u043c \u0434\u0443\u0431\u043e\u043c \u0432\u043e\u0437\u043d\u0438\u043a \u0432 \u0434\u0443\u0448\u0435 \u043a\u043d\u044f\u0437\u044f \u0410\u043d\u0434\u0440\u0435\u044f. \u0412\u043e \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0438\u044f \u043e\u043d \u043a\u0430\u043a \u0431\u0443\u0434\u0442\u043e \u0432\u043d\u043e\u0432\u044c \u043e\u0431\u0434\u0443\u043c\u0430\u043b \u0432\u0441\u044e \u0441\u0432\u043e\u044e \u0436\u0438\u0437\u043d\u044c \u0438 \u043f\u0440\u0438\u0448\u0435\u043b \u043a \u0442\u043e\u043c\u0443 \u0436\u0435 \u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443, \u0443\u0441\u043f\u043e\u043a\u043e\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u043c\u0443 \u0438 \u0431\u0435\u0437\u043d\u0430\u0434\u0435\u0436\u043d\u043e\u043c\u0443, \u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e, \u0447\u0442\u043e \u0435\u043c\u0443 \u043d\u0430\u0447\u0438\u043d\u0430\u0442\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u0431\u044b\u043b\u043e \u043d\u0435 \u043d\u0430\u0434\u043e, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0436\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u0436\u0438\u0437\u043d\u044c, \u043d\u0435 \u0434\u0435\u043b\u0430\u044f \u0437\u043b\u0430, \u043d\u0435 \u0442\u0440\u0435\u0432\u043e\u0436\u0430\u0441\u044c \u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0436\u0435\u043b\u0430\u044f.<\/p>\n<\/div><\/div>\n<p>  <\/p>\n<p>\u041f\u0430\u0442\u0442\u0435\u0440\u043d\u044b:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0434\u0443\u0431<\/li>\n<li>\u0410\u043d\u0434\u0440\u0435\u0439<\/li>\n<li>\u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d<\/li>\n<\/ol>\n<p>  <\/p>\n<h4 id=\"rezultaty\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b<\/h4>\n<p>  <\/p>\n<p><strong>Ops\/sec<\/strong><\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/th>\n<th>\u0434\u0443\u0431<\/th>\n<th>\u0410\u043d\u0434\u0440\u0435\u0439<\/th>\n<th>\u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>getSubstringNaive<\/td>\n<td>57,320<\/td>\n<td>29,506<\/td>\n<td>21,596<\/td>\n<\/tr>\n<tr>\n<td>getSubstringKMP<\/td>\n<td>149,516<\/td>\n<td>163,727<\/td>\n<td>129,087<\/td>\n<\/tr>\n<tr>\n<td>getSubstringNotSoNaive<\/td>\n<td>161,560<\/td>\n<td>176,117<\/td>\n<td>136,640<\/td>\n<\/tr>\n<tr>\n<td>getSubstringBMBadCharacter<\/td>\n<td>246,769<\/td>\n<td>376,072<\/td>\n<td>409,002<\/td>\n<\/tr>\n<tr>\n<td>getSubstringRK<\/td>\n<td>153,172<\/td>\n<td>155,100<\/td>\n<td>152,668<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p><strong>\u041a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439<\/strong><\/p>\n<p>  <\/p>\n<div class=\"scrollable-table\">\n<table>\n<thead>\n<tr>\n<th>\u0410\u043b\u0433\u043e\u0440\u0438\u0442\u043c<\/th>\n<th>\u0434\u0443\u0431<\/th>\n<th>\u0410\u043d\u0434\u0440\u0435\u0439<\/th>\n<th>\u043e\u0431\u043b\u043e\u043c\u0430\u043d\u043d<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>getSubstringNaive<\/td>\n<td>5,013<\/td>\n<td>10,008<\/td>\n<td>13,328<\/td>\n<\/tr>\n<tr>\n<td>getSubstringKMP<\/td>\n<td>1,741<\/td>\n<td>1,688<\/td>\n<td>1,832<\/td>\n<\/tr>\n<tr>\n<td>getSubstringNotSoNaive<\/td>\n<td>1,739<\/td>\n<td>1,683<\/td>\n<td>1,828<\/td>\n<\/tr>\n<tr>\n<td>getSubstringBMBadCharacter<\/td>\n<td>601<\/td>\n<td>327<\/td>\n<td>283<\/td>\n<\/tr>\n<tr>\n<td>getSubstringBMGoodSuffix<\/td>\n<td>1,692<\/td>\n<td>1,680<\/td>\n<td>1,690<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>  <\/p>\n<p>\u041d\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u0442\u0435\u043a\u0441\u0442\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0434\u0435\u0440\u0436\u0438\u0442 \u043f\u043b\u0430\u043d\u043a\u0443 \u043f\u043e <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/formulas\/ac3\/7d5\/1db\/ac37d51db7de582ffae9bafb87b6f5ec.svg\" alt=\"$O(n * m)$\" data-tex=\"inline\"\/>, \u0435\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u043a\u0430\u043a \u0443 \u041a\u041c\u041f \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438 \u00b1 \u0442\u0430\u043a\u043e\u0435 \u0436\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  <\/p>\n<h2 id=\"vyvody\">\u0412\u044b\u0432\u043e\u0434\u044b<\/h2>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0448\u0443\u0441\u0442\u0440\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0447\u0442\u0435\u043d\u0438\u044f, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043a\u0440\u0443\u0442\u0430\u044f \u0444\u0438\u0448\u043a\u0430: \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0432 \u043d\u0435\u0442\u043e\u0447\u043d\u044b\u0439 \u043f\u043e\u0438\u0441\u043a. \u0422\u0430\u043a \u043a\u0430\u043a \u043e\u043d \u043d\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0442\u043e \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0448\u0443\u0441\u0442\u0440\u043e \u0438\u0441\u043a\u0430\u0442\u044c \u0432 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430. \u0417\u043d\u0430\u0447\u0438\u0442 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043b\u044f\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u043a\u0438 \u043f\u0440\u0435\u043f\u0438\u043d\u0430\u043d\u0438\u044f, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0442\u0435\u043a\u0441\u0442 \u0432 \u043d\u0438\u0436\u043d\u0438\u0439 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0430\u0431\u0437\u0430\u0446\u0430 \u0432 \u0442\u0435\u043a\u0441\u0442. \u0414\u0430, \u0435\u0441\u043b\u0438 \u043f\u043e\u0438\u0437\u0433\u043e\u043b\u044f\u0442\u044c\u0441\u044f, \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0431\u0435\u0437 \u0420\u041a \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0432\u044b\u0439\u0434\u0435\u0442 \u043d\u0435 \u0442\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/662678\/\"> https:\/\/habr.com\/ru\/post\/662678\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0445\u0438\u0442\u0440\u043e\u0443\u043c\u043d\u044b\u0439 \u0438 \u043d\u0435\u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435. \u041e\u043d \u043e\u0441\u043d\u043e\u0432\u0430\u043d \u043d\u0435 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0430 \u043d\u0430 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0438 \u0447\u0438\u0441\u0435\u043b. \u042f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u043e\u044f \u0446\u0435\u043b\u044c \u044d\u0442\u043e \u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0440\u0430\u0437\u0431\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432, \u0430 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0438\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c, \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u043c\u0435\u0441\u0442\u0430 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0438\u0445 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439.<br \/>  \u0418 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0435\u0441\u0442\u044c \u0447\u0442\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-332425","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332425","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=332425"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/332425\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=332425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=332425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=332425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}