Exponentiation

Time Limit: 2000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 10319    Accepted Submission(s): 3027

Problem 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

利用BigDecimal

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
BigDecimal a;
while(in.hasNextBigDecimal()) {
a=in.nextBigDecimal();
int b=in.nextInt();
String s=a.pow(b).stripTrailingZeros().toPlainString(); //最后成了字符串。
if(s.startsWith("0")) {
s=s.substring(1);
} //startsWith()是判断字符串是否以某个字符串开头,若是,返回true,String.substring(int start)参数:start:要截取位置的索引。返回:从start开始到结束的字符串。

System.out.println(s);
}
}
}

( 大数 startsWith substring) Exponentiation hdu1063的更多相关文章

  1. LeetCode---String

    Count and Say 思路:递归求出n - 1时的字符串,然后双指针算出每个字符的次数,拼接在结果后面 public String countAndSay(int n) { if(n == 1) ...

  2. Arduino101学习笔记(二)—— 一些注意的语法点

    1.宏定义 2.整数常量 3.支持C++ String类 (1)String 方法 charAt() compareTo() concat() endsWith() equals() equalsIg ...

  3. 嵌入式 python之str操作

    1.字符串的对齐方式:①:center(int[,str])>>> string = 'Fishhat'>>> string.center(55)'         ...

  4. Python学习笔记5(字符串与正则表达式)

    1.字符串 1.1字符串的格式化 #格式化语法 "%s" % str1 "%s %s" % (str1,str2) #格式化字符串 str1 = "v ...

  5. EL函数和自定义EL函数

    简介 EL原本是JSTL1.0中的技术(所以EL和JSTL感情如此好就是自然的了),但是从JSP2.0开始,EL就分离出来纳入了JSP的标准了.但是EL函数还是和JSTL技术绑定在一起.下面将介绍如何 ...

  6. 208道面试题(JVM部分暂无答案)

    这是从网上看到的一套java面试题, 答案只是一个大概, 另外题目质量参差不齐, 斟酌参考(JVM的部分暂时没有答案) 一.Java 基础 JDK 和 JRE 有什么区别? 答: JDK(Java D ...

  7. Arduino语法详解_含示例详解

    Arduino 的程序可以划分为三个主要部分:结构.变量(变量与常量).函数. 结构部分 一.结构 1.1 setup() 1.2 loop() 二.结构控制 2.1 if 2.2 if...else ...

  8. Python 字符串基本操作

    字符串是Python的一种基本类型,字符串的操作包括字符串格式化输出.字符串的截取.合并,字符串的查找和替换等操作. 字符串定义 Python中有3种表示字符串的方法:单引号.双引号.三引号.引号使用 ...

  9. 【JSP】EL函数和自定义EL函数

    简介 EL原本是JSTL1.0中的技术(所以EL和JSTL感情如此好就是自然的了),但是从JSP2.0开始,EL就分离出来纳入了JSP的标准了.但是EL函数还是和JSTL技术绑定在一起.下面将介绍如何 ...

随机推荐

  1. 【CV】ICCV2015_Describing Videos by Exploiting Temporal Structure

    Describing Videos by Exploiting Temporal Structure Note here: it's a learning note on the topic of v ...

  2. 基于SSH 供应链管理系统质量属性说明

    产品的易用程度如何,执行速度如何,可靠性如何,当发生异常情况时,系统如何处理.这些被称为软件质量属性,而特性是指系统非功能(也叫非行为)部分的需求. 性能:性能就是一个东西有多快,通常指响应时间或延迟 ...

  3. python2 与 python3 实现共存

    已有配置  Anaconda2+python2.7 方案一:直接安装官网原生python3.6 1.修改根目录下python.exe ->python3.exe    pythonw.exe - ...

  4. [buaa-SE-2017]个人项目

    个人项目 Part1:github https://github.com/Aria-K-Alethia/Sudoku Part2:解题思路描述 关于数独的解法 我选择的是暴力搜索算法. (1)关于 - ...

  5. Export OracleDB Schema To Doc

    叶正盛先生做的mini工具. https://github.com/rgqancy/DBExportDoc 使用中遇到过两个小问题: 1.数据库的表名不能带.(我一个很初级的同事建立的数据库是demo ...

  6. CAS的应用场景

    国外应用(需FQ尝试): 来自CAS官网推荐的Demo http://casserver.herokuapp.com/cas/login https://casserver.herokuapp.com ...

  7. spring-web-4.3.3与spring-webmvc-4.3.3的区别

    spring-web-4.3.3 http(http协议的实现类)和web包(应用,上下文,会话,cookies,过滤器等等) spring-webmvc-4.3.3 主要是一些view层的核心封装, ...

  8. 转帖 云和恩墨 http://www.eygle.com/archives/2015/06/sql_version_count.html

    SQL多版本控制 - _CURSOR_OBSOLETE_THRESHOLD   作者:eygle |English [转载时请标明出处和作者信息]|[恩墨学院 OCM培训传DBA成功之道]链接:htt ...

  9. SAP字体调节大小

    登陆SAP 之后,菜单下面一行,最右边的那个彩色按钮(SAP GUI),点击“选项”-可视设计-字体设计-固定狂赌字体设计,点击:选择字体 即可.

  10. (String)强制转换、toString()和String.valueOf()的区别

    String:毫无疑问,这种就是强转形式,简单方便,效率高.java程序员可能看到效率高或许有些激动,但是它有他的不好,那就是局限性.在java的世界里没有什么东西是没有缺点的,总有一些好的方面同时也 ...