Exponentiation
Time Limit: 500MS   Memory Limit: 10000K
Total Submissions: 162918   Accepted: 39554

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.

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

Hint

If you don't know how to determine wheather encounted the end of input:  s is a string and n is an integer

C++
while(cin>>s>>n)
{
...
}
c
while(scanf("%s%d",s,&n)==2) //to see if the scanf read in as many items as you want
/*while(scanf(%s%d",s,&n)!=EOF) //this also work */
{
...
}

Source

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner sc1=new Scanner(System.in); while(sc1.hasNextBigDecimal()){
BigDecimal r=sc1.nextBigDecimal();
int n=sc1.nextInt();
BigDecimal answerBigdecimal=r.pow(n);
answerBigdecimal=answerBigdecimal.stripTrailingZeros();
String anString=answerBigdecimal.toPlainString();
if(anString.startsWith("0.")){
anString=anString.substring(1);
}
System.out.println(anString); } }
}

poj1001_Exponentiation_java高精度的更多相关文章

  1. CSharpGL(28)得到高精度可定制字形贴图的极简方法

    CSharpGL(28)得到高精度可定制字形贴图的极简方法 回顾 以前我用SharpFont实现了解析TTF文件从而获取字形贴图的功能,并最终实现了用OpenGL渲染文字. 使用SharpFont,美 ...

  2. 递推+高精度 UVA 10497 Sweet Child Makes Trouble(可爱的孩子惹麻烦)

    题目链接 题意: n个物品全部乱序排列(都不在原来的位置)的方案数. 思路: dp[i]表示i个物品都乱序排序的方案数,所以状态转移方程.考虑i-1个物品乱序,放入第i个物品一定要和i-1个的其中一个 ...

  3. [Template]高精度模板

    重新写一下高精度模板(不要问我为什么) 自认为代码风格比较漂亮(雾 如果有更好的写法欢迎赐教 封装结构体big B是压位用的进制,W是每位长度 size表示长度,d[]就是保存的数字,倒着保存,从1开 ...

  4. Code[VS] 3123 高精度练习之超大整数乘法

    FFT 做 高精度乘法 #include <bits/stdc++.h> ); struct complex { double a, b; inline complex( , ) { a ...

  5. Java 高精度数字

    BigInteger // 高精度整数 BigDecimal //高精度小数  小数位数不受限制

  6. c++减法高精度算法

    c++高精度算法,对于新手来说还是一大挑战,只要克服它,你就开启了编程的新篇章,算法. 我发的这个代码并不是很好,占用内存很多而且运行时间很长(不超过0.02秒),但是很好理解,很适合新手 高精算法的 ...

  7. c++加法高精度算法

    c++高精度算法,对于新手来说还是一大挑战,只要克服它,你就开启了编程的新篇章,算法. 我发的这个代码并不是很好,占用内存很多而且运行时间很长(不超过1秒),但是很好理解,很适合新手 高精算法的本质就 ...

  8. [转]使用Stopwatch类实现高精度计时

    对一段代码计时同查通常有三种方法.最简单就是用DateTime.Now来进行比较了,不过其精度只有3.3毫秒,可以通过DllImport导入QueryPerformanceFrequency和Quer ...

  9. .net平台下获取高精度时间类

    原文:http://www.it118.org/specials/321869dd-98cb-431b-b6d2-82d973cd739d/d940a15c-0d36-4369-8de0-b07cf3 ...

随机推荐

  1. Windows phone应用开发[21]-图片性能优化

    在windows phone 中常在列表中会常包含比较丰富文字和图片混排数据信息. 针对列表数据中除了谈到listbox等控件自身数据虚拟化问题外.虽然wp硬件设备随着SDK 8.0 发布得到应用可使 ...

  2. 如何对多个属性进行transform

    w3school对transform的介绍很简单 transform: none|transform-functions; transform的默认值是none 其所举的例子也只是对一个值进行过渡,其 ...

  3. JavaScript语法规范

    推荐的JavaScript编码规范 阅读 247 评论 0 喜欢 0 作为前端开发人员,我相信每一个人都或多或少的用到原生的JavaScript,也正是因为用的人多,导致编码风格也是多种多样的,而不规 ...

  4. linux终端常用快捷键

    Ctrl + d       删除一个字符,相当于通常的Delete键(命令行若无任何字符,则相当于exit:处理多行标准输入时也表示EOF ) Ctrl + h       退格删除一个字符,相当于 ...

  5. BLE 蓝牙协议栈开发

    1.由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(1) 2.由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(2) 3.由浅入深,蓝牙4.0/BLE协议栈开发攻略大全(3)

  6. [转]Struts2理解--动态方法和method属性及通配符_默认Action

    众所周知,默认条件下,在浏览器输入indexAction!execute.action,便会执行indexAction类里的execute方法,这样虽然方便,但可能带来安全隐患,通过url可以执行Ac ...

  7. SqlServer基础复习

    一.数据类型      包括整数类型(可以用来做主键)的如bit,int ,samllint,tinyint,bigint,存储的范围不同,常用的有int,bigint等:树脂类型decimal(p, ...

  8. 消息中间件:RabbitMQ基本探索

    RabbitMQ是一个基于AMQP协议(Advanced Message Queuing Protocol,一个提供统一消息服务的应用层标准高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中 ...

  9. windows 下 新建 点开头的文件和文件夹

    新建 .aaa文件夹 cmd:$ mkdir .aaa 新建 .aaa文件夹 echo " >> .aaa

  10. Nginx简易配置文件(二)(反向代理)

    user nobody nobody; worker_processes 4; error_log logs/error.log; pid logs/nginx.pid; events { use e ...