博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj1001--Exponentiation
阅读量:4577 次
发布时间:2019-06-08

本文共 1694 字,大约阅读时间需要 5 分钟。

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 R
n
 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 120.4321 205.1234 156.7592  998.999 101.0100 12

Sample Output

548815620517731830194541.899025343415715973535967221869852721.0000000514855464107695612199451127676715483848176020072635120383542976301346240143992025569.92857370126648804114665499331870370751166629547672049395302429448126.76412102161816443020690903717327667290429072743629540498.1075960194566517745610440100011.126825030131969720661201
import java.util.*;import java.io.*;import java.math.*;class Main{    public static void main(String args[])    {        Scanner cin = new Scanner(System.in);        while(cin.hasNext()) {            BigDecimal val = cin.nextBigDecimal();            int n = cin.nextInt();            BigDecimal ret = val.pow(n).stripTrailingZeros();            System.out.println(ret.toPlainString().replaceAll("^0", ""));        }        }}

 

转载于:https://www.cnblogs.com/xueda120/p/3570541.html

你可能感兴趣的文章
vim 使用技巧
查看>>
Periodic String UVa1225
查看>>
Android 演示 DownloadManager——Android 下载 apk 包并安装
查看>>
采用oracle存储过程读取excel文件更新表
查看>>
固定虚拟机中windows系统的ip地址
查看>>
【转】正则应用实例,如将多个空格改为1个空格
查看>>
移动端自动打包平台
查看>>
gradle 使用总结
查看>>
C#函数式程序设计初探——重构应用篇
查看>>
兼容的获取选择文本方法
查看>>
谈一谈git和SVN两大版本管理工具。
查看>>
【1】Bootstrap入门引言
查看>>
PhpExcel中文帮助手册|PhpExcel使用方法
查看>>
Linux下安装rpm出现error: Failed dependencies
查看>>
Chapter 6 排序
查看>>
通用的运营商/数字在C#
查看>>
7kyu Jaden Casing Strings
查看>>
主流编程语言的大概方向(个人理解)
查看>>
2015 HUAS Provincial Select Contest #1 A
查看>>
逆向工程——注册篇
查看>>