{"id":57,"date":"2011-08-31T04:57:35","date_gmt":"2011-08-31T04:57:35","guid":{"rendered":"http:\/\/www.uturtle.com\/blog\/archives\/57"},"modified":"2013-05-12T19:16:03","modified_gmt":"2013-05-12T19:16:03","slug":"uva-%eb%92%a4%ec%a7%91%ec%96%b4%ec%84%9c-%eb%8d%94%ed%95%98%ea%b8%b0-10018","status":"publish","type":"post","link":"https:\/\/www.jinukbaek.com\/blog\/ko\/archives\/57","title":{"rendered":"[UVA] \ub4a4\uc9d1\uc5b4\uc11c \ub354\ud558\uae30 &#8211; 10018"},"content":{"rendered":"<p>\ub2e8\uc21c\ud55c \uc2e4\uc218 \ub54c\ubb38\uc5d0 \uba87\ubc88 \uc2e4\ud328 \ud588\ub2e4.. \ucd9c\ub825\ud560 \ub54c \uac1c\ud589\uc5d0 \uc8fc\uc758\ud574\uc57c\ud560 \uac83 \uac19\ub2e4.<\/p>\n<div class=\"txc-textbox\" style=\"border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-color: rgb(238, 238, 238); border-right-color: rgb(238, 238, 238); border-bottom-color: rgb(238, 238, 238); border-left-color: rgb(238, 238, 238); background-color: rgb(238, 238, 238); padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; \">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">import java.math.BigInteger;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">import java.util.Scanner;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">public class Main {<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t<\/span>public static void main(String[] args)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>Scanner scan = new Scanner(System.in);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>int testcase;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>testcase = scan.nextInt();<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>while (testcase&#8211; &gt; 0)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>BigInteger n = scan.nextBigInteger();<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>int count = 0;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>boolean sign = true;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>while (sign)<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>String n1 = n.toString();<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>StringBuffer sb1 = new StringBuffer(n1);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>String n2 = sb1.reverse().toString();<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>if (n1.equals(n2))<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t\t<\/span>sign = false;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>else<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>{<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t\t<\/span>BigInteger p1 = new BigInteger(n1);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t\t<\/span>BigInteger p2 = new BigInteger(n2);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t\t<\/span>n = p1.add(p2);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t\t<\/span>count++;<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">\n<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t<\/span>System.out.println(count + &#8221; &#8221; + n);<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t\t\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t<\/span>}<\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \"><span class=\"Apple-tab-span\" style=\"white-space: pre; \">\t<\/span><\/p>\n<p style=\"margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; \">}<\/p>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\ub2e8\uc21c\ud55c \uc2e4\uc218 \ub54c\ubb38\uc5d0 \uba87\ubc88 \uc2e4\ud328 \ud588\ub2e4.. \ucd9c\ub825\ud560 \ub54c \uac1c\ud589\uc5d0 \uc8fc\uc758\ud574\uc57c\ud560 \uac83 \uac19\ub2e4. import java.math.BigInteger; import java.util.Scanner; public class<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[74],"tags":[],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-algorithm"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8gT1J-V","_links":{"self":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":1,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":88,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/posts\/57\/revisions\/88"}],"wp:attachment":[{"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinukbaek.com\/blog\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}