{"id":3971,"date":"2018-12-03T20:12:14","date_gmt":"2018-12-03T17:12:14","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=3971"},"modified":"2018-12-25T20:06:18","modified_gmt":"2018-12-25T17:06:18","slug":"e-olymp-2892-%d1%81%d1%83%d0%bc%d0%bc%d0%b0-%d0%b7%d0%bd%d0%b0%d1%87%d0%b5%d0%bd%d0%b8%d0%b9","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=3971","title":{"rendered":"e-olymp 2892. \u0421\u0443\u043c\u043c\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439"},"content":{"rendered":"<h1>\u0417\u0430\u0434\u0430\u0447\u0430<\/h1>\n<p>\u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u0443\u043c\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438<br \/>\n$$f \\left(x \\right ) = x + \\frac{1}{x}$$<br \/>\n\u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0442\u043e\u0447\u043a\u0430\u0445.<\/p>\n<h1>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h1>\n<p>\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a $n$ $\\left (1 \\leqslant n \\leqslant 50 \\right ).$ \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u044b $n$ \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b $x_1, x_2, &#8230;, x_n$ &#8212; \u0442\u043e\u0447\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c $\\left (0 \\leqslant \\left |x_i \\right | \\leqslant 10^9 \\right ).$<\/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\u043e \u0447\u0438\u0441\u043b\u043e &#8212; \u0441\u0443\u043c\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 $f \\left(x \\right )$ \u0432 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u0447\u043a\u0430\u0445. \u041e\u0442\u0432\u0435\u0442 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c, \u0435\u0441\u043b\u0438 \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u0430\u044f \u0438\u043b\u0438 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u043e\u0433\u0440\u0435\u0448\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u0435\u0442 $10^{-9}.$<\/p>\n<h1>\u0422\u0435\u0441\u0442\u044b<\/h1>\n<table>\n<tbody>\n<tr>\n<td><strong>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/td>\n<td><strong>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/strong><\/td>\n<\/tr>\n<tr>\n<td>$3$<\/td>\n<td>$7.833333333333333$<\/td>\n<\/tr>\n<tr>\n<td>$1 \\ 2 \\ 3$<\/td>\n<\/tr>\n<tr>\n<td>$2$<\/td>\n<td>$0$<\/td>\n<\/tr>\n<tr>\n<td>$1 \\ -1$<\/td>\n<\/tr>\n<tr>\n<td>$5$<\/td>\n<td>$4.265140415140415$<\/td>\n<\/tr>\n<tr>\n<td>$10 \\ -13 \\ 21 \\ -18 \\ 4$<\/td>\n<\/tr>\n<tr>\n<td>$1$<\/td>\n<td>$10.1$<\/td>\n<\/tr>\n<tr>\n<td>$10$<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h1>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h1>\n<pre class=\"lang:java decode:true \" title=\"e-olymp 2892  Sum of values\">import java.util.Scanner;\r\nimport java.util.ArrayList;\r\nimport java.math.BigDecimal; \r\n \r\npublic class Main {\r\n\tpublic static void main (String[] args) {\r\n\t\tScanner scanner = new Scanner(System.in);\r\n\t\tint n = scanner.nextInt();\r\n\t\tBigDecimal ans = new BigDecimal(0);\r\n\t\tArrayList&lt;BigDecimal&gt; a = new ArrayList&lt;BigDecimal&gt;();\r\n\t\tfor(int i=0; i&lt;n; i++) {\r\n\t\t\tBigDecimal x = scanner.nextBigDecimal();\r\n\t\t\ta.add(x);\r\n\t\t}\r\n\t\tfor(int i=0; i&lt;n; i++) {\r\n\t\t\tBigDecimal w = a.get(i);\t\t\r\n\t\t\tBigDecimal v = new BigDecimal(1); \r\n\t\t\tans = ans.add(w.add(v.divide(w, 15, BigDecimal.ROUND_HALF_UP)));\r\n\t\t}\r\n\t\tSystem.out.println(ans);\r\n\t}\r\n}<\/pre>\n<h1>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h1>\n<p>\u041c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0443\u043c\u043c\u0438\u0440\u0443\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0442\u043e\u0447\u043a\u0435. \u0422\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 <code>BigDecimal<\/code> \u0434\u043b\u044f \u0442\u043e\u0447\u0435\u043a \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u0438.<\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p><a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/2892\" rel=\"noopener\" target=\"_blank\">\u0423\u0441\u043b\u043e\u0432\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430 e-olymp<\/a><br \/>\n<a href=\"https:\/\/ideone.com\/u82c2l\" rel=\"noopener\" target=\"_blank\">\u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u041d\u0430\u0439\u0434\u0438\u0442\u0435 \u0441\u0443\u043c\u043c\u0443 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 $$f \\left(x \\right ) = x + \\frac{1}{x}$$ \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0446\u0435\u043b\u044b\u0445 \u0442\u043e\u0447\u043a\u0430\u0445. \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a $n$ $\\left (1 \\leqslant n \\leqslant 50 \\right ).$ \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0437\u0430\u0434\u0430\u043d\u044b $n$ \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b $x_1, x_2, &#8230;, x_n$ &#8212; \u0442\u043e\u0447\u043a\u0438, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c $\\left (0 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=3971\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":122,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[107],"tags":[492,493,494],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3971"}],"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\/122"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3971"}],"version-history":[{"count":2,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3971\/revisions"}],"predecessor-version":[{"id":3973,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/3971\/revisions\/3973"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3971"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3971"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3971"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}