{"id":294852,"date":"2019-11-19T15:00:30","date_gmt":"2019-11-19T15:00:30","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=294852"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=294852","title":{"rendered":"\u0417\u0430\u0434\u0430\u0447\u0430 \u0441 TopCoder Open 2019: \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0435\u043c \u043f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u0435\u0439"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ap\/lf\/8o\/aplf8on_nfibutu005flt6pwwmy.jpeg\" alt=\"image\"><\/div>\n<p>  \u041f\u043e \u0441\u043b\u0435\u0434\u0430\u043c <a href=\"https:\/\/habr.com\/ru\/company\/edison\/blog\/476270\/\">\u00ab\u041d\u0430\u0448\u0438 \u043f\u043e\u0431\u0435\u0434\u0438\u043b\u0438: TopCoder Open 2019\u00bb<\/a> \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0442\u0440\u0435\u043a\u0430 Algorithm <i>(\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0417\u0430 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u0447\u0430\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 Java, C#, C++ \u0438\u043b\u0438 Python.)<\/i><\/p>\n<h3>1. \u041f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u0435\u0440\u044b\u0445<\/h3>\n<p>  <b>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/b><\/p>\n<p>  \u041b\u0438\u043c\u0438\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u2014 4 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0438\u0440\u043e\u0433. \u0415\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0432\u0435\u0440\u0445\u0443, \u043f\u0438\u0440\u043e\u0433 \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 (\u0441\u0442\u0440\u043e\u0433\u043e) \u0432\u044b\u043f\u0443\u043a\u043b\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430. \u0412\u0430\u043c \u0434\u0430\u043d\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430\u0445 X \u0438 Y.<\/p>\n<p>  \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u044f\u0442\u044c \u0434\u0440\u0443\u0437\u0435\u0439. \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u0435\u0439 \u0440\u0430\u0432\u043d\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 (\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u044b). \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430 \u043f\u044f\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0444\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0430 \u0442\u0440\u0438 \u0440\u0430\u0437\u0440\u0435\u0437\u0430.<\/p>\n<p>  \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0442\u0440\u0438 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u0443 \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0435\u043b\u044f\u0442 \u043f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u044b\u0445 \u043f\u043e \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0447\u0430\u0441\u0442\u0435\u0439. \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 {x, y, d1, d2, d3}, \u0433\u0434\u0435 (x, y) \u2014 \u043e\u0431\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432, \u0430 d1, d2, d3 \u2014 \u0443\u0433\u043b\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u0430\u0445.<br \/>   <a name=\"habracut\"><\/a>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Definition<\/b><\/p>\n<div class=\"spoiler_text\">Class: CakeForSix<br \/>  Method: cut<br \/>  Parameters: int[], int[]<br \/>  Returns: double[]<br \/>  Method signature: double[] cut(int[] x, int[] y)<br \/>  (be sure your method is public)  <\/div>\n<\/div>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u044f <\/b><\/p>\n<ul>\n<li>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 \u0445 \u0440\u0430\u0432\u043d\u043e 0 (\u0440\u0430\u0434\u0438\u0430\u043d), \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 y \u0440\u0430\u0432\u043d\u043e pi\/2 (\u0440\u0430\u0434\u0438\u0430\u043d).<\/li>\n<li>\u0420\u0430\u0437\u0440\u0435\u0437 \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 d \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u0440\u0430\u0437\u0440\u0435\u0437\u0443 \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 pi*k+d \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e \u0446\u0435\u043b\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 k.<\/li>\n<li>\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043b\u044e\u0431\u044b\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043e\u0442 [0, pi).<\/li>\n<li>\u0413\u0440\u0435\u0439\u0434\u0435\u0440 \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0432\u0430\u0448\u0438\u0445 \u0448\u0435\u0441\u0442\u0438 \u043a\u0443\u0441\u043e\u0447\u043a\u043e\u0432 \u0442\u043e\u0440\u0442\u0430 \u0432 doubles. \u041e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442, \u0435\u0441\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0438\u043b\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043c\u0435\u043d\u044c\u0448\u0435 10^(-4).<\/li>\n<li>\u0422\u043e\u0447\u043d\u0435\u0435, \u043f\u0443\u0441\u0442\u044c X \u0438 Y \u0431\u0443\u0434\u0443\u0442 \u0441\u0430\u043c\u044b\u043c\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u043c\u0438 \u0438 \u0441\u0430\u043c\u044b\u043c\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0438\u0437 \u0432\u0430\u0448\u0438\u0445 \u0448\u0435\u0441\u0442\u0438 \u043e\u0431\u043b\u0430\u0441\u0442\u0435\u0439, \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0433\u0440\u0435\u0439\u0434\u0435\u0440\u043e\u043c. \u0422\u043e\u0433\u0434\u0430 \u0432\u0430\u0448 \u043e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442, \u0435\u0441\u043b\u0438 Y &lt;max (X+10^(-4), X*1+10^(-4))).<\/li>\n<li>(\u0412 \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c 1e-7 \u0432\u043c\u0435\u0441\u0442\u043e 1e-4. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u043f\u0440\u0435\u0434\u0435\u043b \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u043b \u0441\u043d\u0438\u0436\u0435\u043d \u0438\u0437-\u0437\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0432\u044b\u0437\u043e\u0432\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u043d\u0435\u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043c\u043e\u0439 \u0441 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c\u044e 1e-7. \u0412 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043c\u0438\u0440\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0434\u043e\u043f\u0443\u0441\u043a\u0430\u044e\u0442 \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0438 \u0432\u0441\u0435 \u0435\u0449\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0449\u0435\u0439 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0439 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e.)<\/li>\n<\/ul>\n<p>  <b>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f<\/b><\/p>\n<ul>\n<li>x \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0442 3 \u0434\u043e 50 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e.<\/li>\n<li>y \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432, \u0447\u0442\u043e \u0438 x.<\/li>\n<li>\u0432\u0441\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043c\u0435\u0436\u0434\u0443 0 \u0438 10 000 \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e <\/li>\n<li>x \u0438 y \u0437\u0430\u0434\u0430\u044e\u0442 \u0432\u044b\u043f\u0443\u043a\u043b\u044b\u0439 \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a \u0432 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0442\u0438\u0432 \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u043a\u0438. <\/li>\n<\/ul>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u043d\u0430 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u043c<\/b><\/p>\n<div class=\"spoiler_text\">\n<h3>Problem Statement<\/h3>\n<p>  Time limit is 4 seconds.<\/p>\n<p>  You have a cake. Seen from above, the cake is a (strictly) convex polygon. You are given the coordinates of its vertices in the int[]s x and y.<\/p>\n<p>  You have five friends. You now want to cut the cake into six pieces of equal area (but not necessarily equal shape). Of course, anyone can do that in five cuts \u2014 but only a true pro can do it in three!<\/p>\n<p>  Find three straight-line cuts passing through the same point that cut the cake into six equally large parts. Return {x, y, d1, d2, d3}, where (x, y) is the common point of the three cuts, and d1, d2, d3 are their directions in radians.<\/p>\n<p>  <b>Definition<\/b><\/p>\n<p>  Class: CakeForSix<br \/>  Method: cut<br \/>  Parameters: int[], int[]<br \/>  Returns: double[]<br \/>  Method signature: double[] cut(int[] x, int[] y)<br \/>  (be sure your method is public)<\/p>\n<p>  <b>Notes<\/b><br \/>   \u2014 The positive direction along the x axis is 0 (radians), the positive direction along the y axis is pi\/2 (radians).<br \/>   \u2014 A cut in direction d is the same as a cut in direction pi*k+d for any integer k.<br \/>   \u2014 You may return any directions, they do not have to be from [0,pi).<br \/>   \u2014 The grader will compute the areas of your six cake pieces in doubles. The answer will be accepted if the relative or absolute difference between them is less than 10^(-4).<br \/>   \u2014 More precisely, let X and Y be the smallest and the largest of your six areas, as computed by the grader. Then, your answer will be accepted if Y &lt; max( X + 10^(-4), X * (1+10^(-4)) ).<br \/>   \u2014 (The original version of the problem used 1e-7 precision instead of 1e-4. For upsolving this problem in the archive the precision limit was lowered due to the existence of challenge cases that most likely make the task unsolvable with 1e-7 precision. In an ideal world the constraints would not allow such cases and still require high precision, so that it isn&#8217;t easy to solve the problem via some general numeric optimization.)<\/p>\n<p>  <b>Constraints<\/b><br \/>   \u2014 x will have between 3 and 50 elements, inclusive.<br \/>   \u2014 y will have the same number of elements as x.<br \/>   \u2014 All coordinates will be between 0 and 10,000, inclusive.<br \/>   \u2014 x and y will describe a convex polygon in counterclockwise order.  <\/div>\n<\/div>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440\u044b<\/h3>\n<p>  <b>0)<\/b> <\/p>\n<p>  {0, 20, 30, 50, 30, 20}<br \/>  {10, 0, 0, 10, 20, 20}<br \/>  Returns: <br \/>  {24.999999999437453, 9.999999999500002, 0.0, 0.7266423406817211, 2.4149503129080787 }<\/p>\n<p>  \u0421\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0447\u043d\u044b\u0439, \u043d\u043e \u043d\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0448\u0435\u0441\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a. \u041f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u0432\u0435\u0442\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043d\u0438\u044e \u0435\u0433\u043e \u043f\u043e\u043f\u043e\u043b\u0430\u043c \u043f\u043e \u0433\u043e\u0440\u0438\u0437\u043e\u043d\u0442\u0430\u043b\u0438 \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044e \u0434\u0432\u0443\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u044e\u0442 \u043a\u0430\u0436\u0434\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u043d\u0430 \u0442\u0440\u0438 \u0447\u0430\u0441\u0442\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d3a\/7d1\/372\/d3a7d137239f73f12ca0057386c3961c.png\" alt=\"image\"><\/p>\n<p>  <b>1)<\/b><\/p>\n<p>  {0, 1000, 0}<br \/>  {0, 0, 1000}<br \/>  Returns: <br \/>  {333.3333333331763, 333.3333333332546, 0.7853981633986264, 2.0344439357948154, 2.6779450445891753 }<\/p>\n<p>  \u041f\u0440\u044f\u043c\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u044b\u0439 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a. \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0442\u0440\u0435\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 \u0441\u0438\u043c\u043c\u0435\u0442\u0440\u0438\u0438.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/cf8\/fb3\/fd3\/cf8fb3fd3a16f75cad3d603230726020.png\" alt=\"image\"><\/p>\n<p>  <b>2)<\/b><\/p>\n<p>  {40, 70, 90, 90, 50}<br \/>  {30, 20, 40, 100, 60}<br \/>  Returns: <br \/>  {69.79517771922892, 52.77575974637605, 2.0616329654335885, 3.637826104091601, 4.32123485812475 }<\/p>\n<p>  \u041d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u044f\u0442\u0438\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/c5d\/48d\/1be\/c5d48d1be3f63ca453e3700492d49d36.png\" alt=\"image\"><\/p>\n<p>  <b>3)<\/b><\/p>\n<p>  {300, 400, 300, 200}<br \/>  {500, 600, 700, 600}<br \/>  Returns: {299.99999999974995, 599.9999999995, 0.0, 1.107148717794088, 2.034443935795705 }<\/p>\n<p>  \u041a\u0432\u0430\u0434\u0440\u0430\u0442, \u043f\u043e\u0432\u0435\u0440\u043d\u0443\u0442\u044b\u0439 \u043d\u0430 45 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e58\/ead\/dd1\/e58eaddd1f31f9a048170e7d54ea0a04.png\" alt=\"image\"><\/p>\n<p>  [<a href=\"https:\/\/community.topcoder.com\/stat?c=problem_statement&amp;pm=15787\">\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a<\/a>]<\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <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\/476500\/\"> https:\/\/habr.com\/ru\/post\/476500\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\">\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ap\/lf\/8o\/aplf8on_nfibutu005flt6pwwmy.jpeg\" alt=\"image\"><\/div>\n<p>  \u041f\u043e \u0441\u043b\u0435\u0434\u0430\u043c <a href=\"https:\/\/habr.com\/ru\/company\/edison\/blog\/476270\/\">\u00ab\u041d\u0430\u0448\u0438 \u043f\u043e\u0431\u0435\u0434\u0438\u043b\u0438: TopCoder Open 2019\u00bb<\/a> \u043f\u0443\u0431\u043b\u0438\u043a\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0438 \u0441 \u0442\u0440\u0435\u043a\u0430 Algorithm <i>(\u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u0441\u043f\u043e\u0440\u0442\u0438\u0432\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0417\u0430 \u043f\u043e\u043b\u0442\u043e\u0440\u0430 \u0447\u0430\u0441\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c \u0442\u0440\u0438 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 Java, C#, C++ \u0438\u043b\u0438 Python.)<\/i><\/p>\n<h3>1. \u041f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u0435\u0440\u044b\u0445<\/h3>\n<p>  <b>\u041f\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0437\u0430\u0434\u0430\u0447\u0438<\/b><\/p>\n<p>  \u041b\u0438\u043c\u0438\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u2014 4 \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<\/p>\n<p>  \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0438\u0440\u043e\u0433. \u0415\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441\u0432\u0435\u0440\u0445\u0443, \u043f\u0438\u0440\u043e\u0433 \u0438\u043c\u0435\u0435\u0442 \u0444\u043e\u0440\u043c\u0443 (\u0441\u0442\u0440\u043e\u0433\u043e) \u0432\u044b\u043f\u0443\u043a\u043b\u043e\u0433\u043e \u043c\u043d\u043e\u0433\u043e\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430. \u0412\u0430\u043c \u0434\u0430\u043d\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u043b\u0430\u0445 X \u0438 Y.<\/p>\n<p>  \u0423 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u044f\u0442\u044c \u0434\u0440\u0443\u0437\u0435\u0439. \u0412\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u044c \u0447\u0430\u0441\u0442\u0435\u0439 \u0440\u0430\u0432\u043d\u043e\u0439 \u043f\u043b\u043e\u0449\u0430\u0434\u0438 (\u043d\u043e \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e\u0439 \u0444\u043e\u0440\u043c\u044b). \u041a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435, \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430 \u043f\u044f\u0442\u044c \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432, \u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0444\u0438 \u043c\u043e\u0436\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0437\u0430 \u0442\u0440\u0438 \u0440\u0430\u0437\u0440\u0435\u0437\u0430.<\/p>\n<p>  \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0442\u0440\u0438 \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u044b\u043c\u0438 \u043b\u0438\u043d\u0438\u044f\u043c\u0438 \u0447\u0435\u0440\u0435\u0437 \u043e\u0434\u043d\u0443 \u0442\u043e\u0447\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u0434\u0435\u043b\u044f\u0442 \u043f\u0438\u0440\u043e\u0433 \u043d\u0430 \u0448\u0435\u0441\u0442\u044c \u0440\u0430\u0432\u043d\u044b\u0445 \u043f\u043e \u043f\u043b\u043e\u0449\u0430\u0434\u0438 \u0447\u0430\u0441\u0442\u0435\u0439. \u0412\u044b\u0432\u0435\u0434\u0438\u0442\u0435 {x, y, d1, d2, d3}, \u0433\u0434\u0435 (x, y) \u2014 \u043e\u0431\u0449\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445 \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432, \u0430 d1, d2, d3 \u2014 \u0443\u0433\u043b\u044b \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0437\u0440\u0435\u0437\u043e\u0432 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u0430\u0445.   <\/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-294852","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294852","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=294852"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/294852\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=294852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=294852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=294852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}