Exponentiation
Time Limit: 500MS | Memory Limit: 10000K | |
Total Submissions: 134694 | Accepted: 32951 |
Description
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.
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 0 < n <= 25.
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 0 < n <= 25.
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 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.
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
package poj; import java.math.BigDecimal; import java.util.Scanner; public class E1001_Exponentiation { public static void main(String[] args){ Scanner in = new Scanner(System.in); BigDecimal r; BigDecimal result; int n; while(in.hasNextLine()){ r = in.nextBigDecimal(); n = in.nextInt(); result = r.pow(n); System.out.println(result.stripTrailingZeros().toPlainString().replaceFirst("^0", "")); } in.close(); } }
相关推荐
根据题目要求,本文将对POJ 1001 Exponentiation这道题进行详细的解析,包括题目背景、输入输出格式、样例分析、解题思路及算法实现等。 ### 题目背景 POJ (Peking University Online Judge) 是一个著名的在线编程...
如题所示,亲测可用。求高精度幂,不会的同学可以参考下,会做的同学可以给挑挑毛病!大家以代码会友!
例如,Exponentiation,可能需要实现快速幂算法来高效地计算大数的指数。 3. **几何**:几何问题要求选手解决与二维或三维几何图形相关的问题,可能涉及点、线、面的关系,如Fence、A decorative fence、Pipe等。这...
- **数学运算**:例如1000A+B是简单的加法运算,1001Exponentiation涉及幂运算。 - **字符串处理**:1256 Anagram检测字符串是否为变位词,1579 Function Run Fun处理字符串函数。 - **排序与比较**:1007 DNA ...
1. 1001 Exponentiation:快速幂运算,理解和实现基本的数学操作。 2. 1002 487-3279:电话号码的转换,了解数字系统和位运算。 3. 1003 Hangover:简单的模拟醉酒状态,注意条件分支。 4. 2301 Beat the Spread!: ...
* 1001 Exponentiation:本题目要求使用编程语言来模拟幂运算。 * 1002 487-3279:本题目要求使用编程语言来模拟电话号码的格式化。 * 1003 Hangover:本题目要求使用编程语言来模拟酒吧的营业情况。 * 1701 ...
* 1001 Exponentiation:这是一个简单的指数运算题目,要求学习者编写一个程序来计算一个数字的幂。 * 1003 Hangover:这是一个简单的字符串处理题目,要求学习者编写一个程序来处理字符串。 搜索题 搜索题是POJ...
2. **数学问题**:包括1001Exponentiation(指数运算)、1014 Dividing(除法问题)、1142 Smith Numbers(史密斯数)、1517 u Calculate e(计算e的值)等,这类题目涉及数学知识,如幂运算、数论、数值计算等,...
2. 1001Exponentiation:该问题可能是关于计算大数的指数幂。 3. 1003Hangover:这个题目可能与数学计算有关,但具体内容需要查询原题。 4. 1004ManagementFinancial:这可能涉及到基本的财务计算。 5. 1013...
3. Exponentiation (POJ1001) 这是关于高精度计算的问题,通常采用快速幂算法求解。快速幂算法利用了幂运算的结合律(a^b)^c = a^(b*c),通过将指数n进行二进制分解,将求a^n转化为一系列乘法操作,极大地减少了计算...