joj1483 Exponentiation
2012-05-05 23:02
190 查看
1483: Exponentiation
Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 365 | 109 | Standard |
This problem requires that you write a program to compute the exact value of Rn where R is a real number ( 0.0 < R < 99.999) and n is an integer such that
.
Input
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.
Output
The output will consist of one line for each line of input giving the exact value of Rn. Leading zeros and insignificant trailing zeros should be suppressed in the output.
Sample Input
95.123 12 0.4321 20 5.1234 15 6.7592 9 98.999 10 1.0100 12
Sample Output
548815620517731830194541.899025343415715973535967221869852721 .00000005148554641076956121994511276767154838481760200726351203835429763013462401 43992025569.928573701266488041146654993318703707511666295476720493953024 29448126.764121021618164430206909037173276672 90429072743629540498.107596019456651774561044010001 1.126825030131969720661201
Submit / Problem List / Status / Discuss
Java除了慢一点,大数处理上绝对很方便...
不过自己用C写也可以练习一下。
这里就用Java吧...
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String args[]) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); BigDecimal num; int n; String str; while(cin.hasNextBigDecimal()) { num = cin.nextBigDecimal(); n = cin.nextInt(); num = num.pow(n); str = num.stripTrailingZeros().toPlainString(); if(str.startsWith("0.")) { str = str.substring(1); } System.out.println(str); } } }
相关文章推荐
- JOJ1483:Exponentiation
- Exponentiation(poj能通过,joj不能)
- No.1001:Exponentiation
- 1001 Exponentiation
- JOJ 1119 1121
- 分酒问题与JOJ 1200 Jugs
- JOJ 1198: Risk
- joj 1020 格式输出
- joj 2319
- joj 2660: 河床 求最长区间满足条件(0<=max-min<=k) 单调队列
- joj 1386解题报告
- joj 1173
- joj 2734: keyword DFA 求字符串最多匹配多少字符串 每个子串最多匹配多少个 优化算法
- joj 2657 简单贪心
- JOJ2519 Find the longest section(位运算 +(前缀和?))
- POJ 1001 Exponentiation 高精度
- joj1059
- joj 2724: Hua Rong Dao 最小割
- joj神一般的循序渐进200题 扩充版
- joj2529