﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-ACM___________________________-随笔分类-JAVA</title><link>http://www.cppblog.com/MiYu/category/14404.html</link><description>                             ______________白白の屋</description><language>zh-cn</language><lastBuildDate>Fri, 10 Sep 2010 10:27:34 GMT</lastBuildDate><pubDate>Fri, 10 Sep 2010 10:27:34 GMT</pubDate><ttl>60</ttl><item><title>HDOJ 1063 HDU 1063 Exponentiation JAVA 编写 ACM 1063 IN HDU</title><link>http://www.cppblog.com/MiYu/archive/2010/09/10/126325.html</link><dc:creator>MiYu</dc:creator><author>MiYu</author><pubDate>Fri, 10 Sep 2010 09:01:00 GMT</pubDate><guid>http://www.cppblog.com/MiYu/archive/2010/09/10/126325.html</guid><wfw:comment>http://www.cppblog.com/MiYu/comments/126325.html</wfw:comment><comments>http://www.cppblog.com/MiYu/archive/2010/09/10/126325.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/MiYu/comments/commentRss/126325.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/MiYu/services/trackbacks/126325.html</trackback:ping><description><![CDATA[<p><span style="font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; line-height: normal; font-size: 13px;">MiYu原创, 转帖请注明 : 转载自&nbsp;<font color="#1d58d1"><a  href="http://www.cnblogs.com/MiYu" style="text-decoration: none; color: #1d58d1;">______________白白の屋</a>&nbsp;&nbsp;<img  src="http://www.cnblogs.com/Emoticons/baimantou/223332482.gif" alt="">&nbsp;&nbsp;</font></span></p>
<p>&nbsp;</p>
<p>题目地址:&nbsp; <a  href="http://acm.hdu.edu.cn/showproblem.php?pid=1063">http://acm.hdu.edu.cn/showproblem.php?pid=1063</a><br></p>
<p>题目描述:<br></p>
<div class="cnblogs_code">
<div><span style="color: #800080;">
<h1>Exponentiation</h1>
<strong><span style="font-family: Arial; font-size: 12px; font-weight: bold; color: green;">Time Limit: 1000/500 MS (Java/Others)&nbsp;&nbsp;&nbsp;&nbsp;Memory Limit: 65536/32768 K (Java/Others)<br>Total Submission(s): 1696&nbsp;&nbsp;&nbsp;&nbsp;Accepted Submission(s): 376<br></span></strong><br><br>
<div align="left">Problem Description</div>
<div>Problems
involving the computation of exact values of very large magnitude and
precision are common. For example, the computation of the national debt
is a taxing experience for many computer systems. <br><br>This problem requires that you write a program to compute the exact value of R<sup>n</sup> where R is a real number ( 0.0 &lt; R &lt; 99.999 ) and n is an integer such that 0 &lt; n &lt;= 25. <br></div>
<div>&nbsp;</div>
<br>
<div align="left">Input</div>
<div>The
input will consist of a set of pairs of values for R and n. The R
value  will occupy columns 1 through 6, and the n value will be in
columns 8  and 9.<br></div>
<div>&nbsp;</div>
<br>
<div align="left">Output</div>
<div>The
output will consist of one line for each line of input giving the
exact  value of R^n. Leading zeros should be suppressed in the output.
Insignificant trailing zeros must not be printed. Don't print the
decimal point if the result is an integer.<br></div>
<div>&nbsp;</div>
<br>
<div align="left">Sample Input</div>
<div>
<pre>
<div style="font-family: Courier New,Courier,monospace;">95.123 12 0.4321 20 5.1234 15 6.7592  9 98.999 10 1.0100 12</div>
</pre>
</div>
<div>&nbsp;</div>
<br>
<div align="left">Sample Output</div>
<div>
<pre>
<div style="font-family: Courier New,Courier,monospace;">548815620517731830194541.899025343415715973535967221869852721 .00000005148554641076956121994511276767154838481760200726351203835429763013462401 43992025569.928573701266488041146654993318703707511666295476720493953024 29448126.764121021618164430206909037173276672 90429072743629540498.107596019456651774561044010001 1.126825030131969720661201</div>
</pre>
</div>
<div>&nbsp;</div>
<p>这两天突然想学习下JAVA 的大数&nbsp; 就学习了一下, 这道题在PKU A掉了的, 不过在 HDU 一直没过, 不知道有什么恶心的数据把我给恶心掉了, 很郁闷.</p>
<p>不过 用JAVA直接 1 A 了........... 很简单的说</p>
<p>&nbsp;</p>
<p>代码如下 :</p>
<p>&nbsp;</p>
<p>/*<br>&nbsp;* To change this template, choose Tools | Templates<br>&nbsp;* and open the template in the editor.<br>&nbsp;*/<br>import java.util.Scanner;<br>import java.math.*;<br><br>/**<br>&nbsp;*<br>&nbsp;* @author baiyun<br>&nbsp;*/<br>public class Main {<br><br>&nbsp;&nbsp;&nbsp; /**<br>&nbsp;&nbsp;&nbsp;&nbsp; * @param args the command line arguments<br>&nbsp;&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Scanner in = new Scanner ( System.in );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; BigDecimal num;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int exp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while ( in.hasNext() ){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = in.nextBigDecimal();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exp = in.nextInt();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = num.pow ( exp );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = num.stripTrailingZeros();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; String out = num.toPlainString();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ( out.charAt(0) == '0' )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; out = out.substring(1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; System.out.println( out );<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>&nbsp;</p>
</span></div>
</div>
<p><br></p>
<p>&nbsp;</p><img src ="http://www.cppblog.com/MiYu/aggbug/126325.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/MiYu/" target="_blank">MiYu</a> 2010-09-10 17:01 <a href="http://www.cppblog.com/MiYu/archive/2010/09/10/126325.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>