{"id":4619,"date":"2018-12-27T20:02:31","date_gmt":"2018-12-27T17:02:31","guid":{"rendered":"http:\/\/java.mazurok.com\/?p=4619"},"modified":"2018-12-27T23:09:03","modified_gmt":"2018-12-27T20:09:03","slug":"e-olymp-313-a-b","status":"publish","type":"post","link":"https:\/\/java.mazurok.com\/?p=4619","title":{"rendered":"e-olymp 313. A + B"},"content":{"rendered":"<h1>A + B<\/h1>\n<p>\u041f\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u043b\u0438 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435: \u043d\u0430\u0439\u0442\u0438 \u0441\u0443\u043c\u043c\u0443 2-\u0445 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b <strong>A<\/strong> \u0438 <strong>B<\/strong>.<\/p>\n<h4>\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h4>\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 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u041f\u0435\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 <strong>N<\/strong>, \u0430 \u0434\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 <strong>N<\/strong> \u0441\u0442\u0440\u043e\u043a \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <strong>A+B<\/strong>, \u0433\u0434\u0435 <strong>A<\/strong> \u0438 <strong>B<\/strong> &#8212; 2 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430, \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f <strong>&#171;+&#187;<\/strong>.<br \/>\n\u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0430\u0442\u0443 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f (\u0441\u043c. \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445). \u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0442 $10^{500}$. $(0 &lt; N &lt;= 250)$<\/p>\n<h4>\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435<\/h4>\n<p>\u0412 <strong>N<\/strong> \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0438\u0441\u043a\u043e\u043c\u044b\u0435 \u0441\u0443\u043c\u043c\u044b.<\/p>\n<h4>\u0422\u0435\u0441\u0442\u044b<\/h4>\n<table>\n<tbody>\n<tr>\n<th>#<\/th>\n<th>\u0412\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/th>\n<th>\u0412\u042b\u0425\u041e\u0414\u041d\u042b\u0415 \u0414\u0410\u041d\u041d\u042b\u0415<\/th>\n<\/tr>\n<tr>\n<th>1<\/th>\n<th>$2$<br \/> $5+3$<br \/> $14818641113280510+52467$<\/th>\n<th>$8$ <br \/> $14818641113332977$<\/th>\n<\/tr>\n<tr>\n<th>2<\/th>\n<th>$1$<br \/> $0+0$<\/th>\n<th>$0$<\/th>\n<\/tr>\n<tr>\n<th>3<\/th>\n<th>$3$<br \/> $1+1$ <br \/> $1+2$ <br \/> $1+3$ <\/th>\n<th>$2$ <br \/> $3$ <br \/> $4$<\/th>\n<\/tr>\n<tr>\n<th>4<\/th>\n<th>$2$<br \/> $123123123 + 321321321$ <br \/> $321321321 + 123123123$<\/th>\n<th>$444444444$ <br \/> $444444444$<\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4>\u041a\u043e\u0434 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b<\/h4>\n<pre class=\"lang:java decode:true \" title=\"e-olymp.313\">import java.util.Scanner;\r\nimport java.math.BigInteger;\r\n\r\nclass Main\r\n{\r\n\tpublic static void main (String[] args) throws java.lang.Exception\r\n\t{\r\n\t\tScanner scan = new Scanner(System.in);\r\n\t\tint n = scan.nextInt();\r\n\t\tscan.nextLine();\r\n\t\twhile(n-- &gt; 0){\r\n\t\t\tString s = scan.nextLine();\r\n\t\t\tint k = s.indexOf('+');\r\n\t\t\tSystem.out.println(new BigInteger(s.substring(0, k)).add(new BigInteger(s.substring(k+1))));\r\n\t\t}\r\n\t}\r\n}<\/pre>\n<h2>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438<\/h2>\n<p>\u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>BigInteger<\/code>, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0432 \u043d\u0430\u0448\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f\u0445 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0447\u0438\u0441\u043b\u0430, \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0449\u0438\u0435 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 <code>Long<\/code>. k-\u0442\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u043c \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0438\u043c \u0441\u0438\u043c\u0432\u043e\u043b <strong>&#171;+&#187;<\/strong>. \u0414\u0430\u043b\u0435\u0435, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0434\u043e k-\u0442\u043e\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u0433\u043e, \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u044f \u044d\u0442\u0438 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>BigInteger<\/code>.<\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>\u2022 \u0417\u0430\u0434\u0430\u0447\u0430 \u043d\u0430 <a href=\"https:\/\/www.e-olymp.com\/ru\/problems\/313\" target=\"_blank\" rel=\"noopener\">e-olymp<\/a>.<\/p>\n<p>\u2022 \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 <a href=\"https:\/\/ideone.com\/Px4C3L\" target=\"_blank\" rel=\"noopener\">ideone<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A + B \u041f\u0435\u0442\u0435 \u0437\u0430\u0434\u0430\u043b\u0438 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435: \u043d\u0430\u0439\u0442\u0438 \u0441\u0443\u043c\u043c\u0443 2-\u0445 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u0435\u043b A \u0438 B. \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 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u041f\u0435\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 N, \u0430 \u0434\u0430\u043b\u0435\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 N \u0441\u0442\u0440\u043e\u043a \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 A+B, \u0433\u0434\u0435 A \u0438 B &#8212; 2 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u0438\u0441\u043b\u0430, \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u0435\u043b\u043e\u0432 \u0441\u0438\u043c\u0432\u043e\u043b \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441\u043b\u043e\u0436\u0435\u043d\u0438\u044f &#171;+&#187;. \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 &hellip; <a href=\"https:\/\/java.mazurok.com\/?p=4619\" class=\"more-link\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":115,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[647,646,147],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4619"}],"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\/115"}],"replies":[{"embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4619"}],"version-history":[{"count":3,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4619\/revisions"}],"predecessor-version":[{"id":4633,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=\/wp\/v2\/posts\/4619\/revisions\/4633"}],"wp:attachment":[{"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/java.mazurok.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}