uva748 - Exponentiation
import java.io.*;
import java.text.*;
import java.util.*;
import java.math.*;
public class Exponentiation {
public static void main(String[] args){
Scanner sc = new Scanner(new BufferedInputStream(System.in));
BigDecimal bd1, ans;
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(110); // 设置最大小数位
int n, i;
String st;
while(sc.hasNextLine()){
st = sc.nextLine();
String[] s = st.split(" +");
bd1 = new BigDecimal(s[0]);
n = Integer.parseInt(s[1].trim());
ans = new BigDecimal("1"); for(i = 1; i <= n; ++i){
ans = ans.multiply(bd1);
}
String result = df.format(ans); String[] str = result.split("\\."); /// '.' 要用 "\\."
//System.out.println(str[0]);
if(str[0].equals("0")){ /// 字符串判断相等 equals()
System.out.println("." + str[1]);
}else{
result = result.replace(",",""); ///将结果中的','号去掉。。。
System.out.println(result);
}
//System.out.println(result);
}
sc.close();
}
}
uva 有时判题不给结果,我擦。。。
uva748 - Exponentiation的更多相关文章
- uva748 - Exponentiation 高精度小数的幂运算
uva748 - Exponentiation Exponentiation Problems involving the computation of exact values of very ...
- 【PKU1001】Exponentiation(高精度乘法)
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 145642 Accepted: 35529 ...
- [POJ] #1001# Exponentiation : 大数乘法
一. 题目 Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 156373 Accepted: ...
- Poj 1001 / OpenJudge 2951 Exponentiation
1.链接地址: http://poj.org/problem?id=1001 http://bailian.openjudge.cn/practice/2951 2.题目: Exponentiatio ...
- POJ 1001 Exponentiation 无限大数的指数乘法 题解
POJ做的非常好,本题就是要求一个无限位大的指数乘法结果. 要求基础:无限大数位相乘 额外要求:处理特殊情况的能力 -- 关键是考这个能力了. 所以本题的用例特别重要,再聪明的人也会疏忽某些用例的. ...
- HDU Exponentiation 1063 Java大数题解
Exponentiation Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Problem F: Exponentiation
Problem F: ExponentiationTime Limit: 1 Sec Memory Limit: 128 MBSubmit: 4 Solved: 2[Submit][Status][W ...
- Exponentiation(java 大实数)
http://acm.hdu.edu.cn/showproblem.php?pid=1063 Exponentiation Time Limit: 2000/500 MS (Java/Others) ...
- ( 大数 startsWith substring) Exponentiation hdu1063
Exponentiation Time Limit: 2000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- 剑指Offer——网易笔试之解救小易
知识要点 首先介绍一下曼哈顿,曼哈顿是一个极为繁华的街区,高楼林立,街道纵横,从A地点到达B地点没有直线路径,必须绕道,而且至少要经C地点,走AC和 CB才能到达,由于街道很规则,ACB就像一个直角3 ...
- 《Thinking in Java》十七章_容器深入研究_练习14(Page486)
练习14 Properties的继承树如下:
- NotePad ++的妙用:添加代码行数和格式不变复制代码
NotePad ++ 不仅安装包小而且功能强大,可以支持很多语言.这里简单阐述下两个功能: 一.在代码前添加行数: 1.用NotePad ++打开一个文件,一般NotePad ++会自动识别这是什么语 ...
- NMON中的各项参数指标
一.NMON中的各项参数指标: SYS_SUMM:显示当前服务器的总体性能情况 Total System I/OStatistics:Avg tps during an interval:显示采集间隔 ...
- zip 压缩文件 unzip查看zip压缩包内的内容
[root@GitLab tmp]# zip -r new.zip ./* adding: gitlab_key_file20161001-2668-1eu44mv (deflated 15%) ...
- MVC学习笔记---ModelBinder
http://www.cnblogs.com/terrysun/archive/2010/04/05/1704666.html http://www.cnblogs.com/aehyok/archiv ...
- linux cpuInfo
转自:http://blog.csdn.net/lgstudyvc/article/details/7889364 /proc/cpuinfo文件分析 在Linux系统中,提供了proc文件系统显 ...
- poj 1003:Hangover(水题,数学模拟)
Hangover Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 99450 Accepted: 48213 Descri ...
- 【openGL】画正弦函数图像
#include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...
- android 入门-动画与容器
set 动画容器 可作为资源id添加R.anim.xxxx 可用于在样式表中添加 http://blog.csdn.net/liuhe688/article/details/6660823 in ...