Exponentiation
Time Limit: 500MS   Memory Limit: 10000K
Total Submissions: 183034   Accepted: 44062

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

题意:

给定一个浮点数R和一个整数n,求R^n

思路:

想给学弟们出一道大数巩固一下。搜到的大数例题。

java BigDecimal自己也都还没用过。

两个点,用 String s = r.pow(n).stripTrailingZeros().toPlainString();使结果不用科学计数法。

注意去掉前导零。比如0.00001要变成 .00001

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

poj1001 Exponentiation【java大数】的更多相关文章

  1. Exponentiation java大数

    Exponentiation 大数a的n次幂,直到读到EOF(文件结尾)为止,其中忽略小数后面的0 1 import java.util.*; 2 import java.math.*; 3 impo ...

  2. 【Java】-BigInteger大数类的使用【超强Java大数模板 总结】

    Scanner cin = new Scanner(new BufferedInputStream(System.in)); 这样定义Scanner类的对象读入数据可能会快一些! 参考这个博客继续补充 ...

  3. java大数

    java大数还是很好用的! 基本加入: import java.math.BigInteger; import jave.math.BigDecimal; 分别是大数和大浮点数. 首先读入可以用: S ...

  4. JAVA大数运算

    java大数是个好东西,用起来方便,代码短. 代码如下: import java.util.*; import java.math.*; public class Main { public stat ...

  5. java大数总结【转】

    java大数(2013长春网络赛)--hdu4762总结一下:1.java提交类要写Main.2.读取大数. Scanner read=new Scanner(System.in); BigInteg ...

  6. HDU5047Sawtooth(java大数)

    HDU5047Sawtooth(java大数) 题目链接 题目大意:在一个矩形内画n个"M".问如何画可以把这个矩形分成最多的区域. 给出这个区域的数目. 解题思路:最好的方式就是 ...

  7. JAVA大数类

    JAVA大数类api http://man.ddvip.com/program/java_api_zh/java/math/BigInteger.html#method_summary 不仅仅只能查J ...

  8. HDU4762(JAVA大数)

    Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  9. ZOJ3477&JAVA大数类

    转:http://blog.csdn.net/sunkun2013/article/details/11822927 import java.util.*; import java.math.BigI ...

  10. 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&amp;记忆化递归

    HDU 4911 Inversion 考点:归并排序 思路:这题呀比赛的时候忘了知道能够用归并排序算出逆序数,可是忘了归并排序的实质了.然后不会做-- 由于看到题上说是相邻的两个数才干交换的时候.感觉 ...

随机推荐

  1. apache 配置会话保持

    1.修改apache_home/conf/httpd.conf,增加以下模块(取消注释,如有其他依赖, 则相应取消注释) LoadModule proxy_module modules/mod_pro ...

  2. pycharm使用docker镜像的python解释器,pycahrm可视化操作和管理dcoker

    网上关于pycahrm怎么使用docker容器的python解释器的科普,这方面太少,一半都只介绍pycahrm怎么使用linux的解释器.首先pycahrm确保是pro版本. 下面详细的介绍步骤 首 ...

  3. selenium +chrome headless Manual 模式渲染网页

    可以看看这个里面的介绍,写得很好.https://duo.com/blog/driving-headless-chrome-with-python from selenium import webdr ...

  4. php 应用 bootstrap-fileinput 上传文件 插件 操作的方法

    //先加载插件所需要的 js .css 文件 <link href="css/fileinput.css" rel="stylesheet" type=& ...

  5. iOS_UITextField 基本操作

    基本操作 UITextField *userNameTextField = [[UITextField alloc] init]; userNameTextField.frame = CGRectMa ...

  6. iOS .tdb代替.dylib

    原文链接:http://www.meniny.cn/2015/09/22/00-00-01-iOS_Xcode_7_tbd/ 不少升级 Xcode 7 的小伙伴们都表示在引入动态库时惊呆了,因为熟悉的 ...

  7. iOS开发-UIImageView响应点击事件

    UIImageView是不能够响应点击事件的,在开发过程中我们需要经常对头像等添加点击事件,上网搜索一番后发现有如下两个方法: 1.找到点击图片Event,添加事件处理函数 UIImageView.u ...

  8. com.baidu.mapapi.CoordType

    2.2.2升级到3.0.1百度报错了, 一:请检查.jar,.so是否是最新的 二:clear

  9. centos6.4安装 jupyter-notebook

    自上次发布了文章后有些网友就说不能实现效果,根据自己的实验发现确实有此事,那是因为版本的变化问题.这次基于yum仓库里的jupyter notebook 5.0.0版本实现: 系统:最小化安装[习惯性 ...

  10. codeforces水题100道 第十七题 Codeforces Beta Round #25 (Div. 2 Only) A. IQ test (brute force)

    题目链接:http://www.codeforces.com/problemset/problem/25/A题意:在n个书中找到唯一一个奇偶性和其他n-1个数不同的数.C++代码: #include ...