POJ 1001 Exponentiation(大数处理)
来源:互联网 发布:把淘宝链接转换成文字 编辑:程序博客网 时间:2024/05/17 00:52
http://poj.org/problem?id=1001
题意:给你一个浮点数,一个整数,求浮点数的整数次方。
思路:大数解决,注意处理后面多余的零跟前面多余的零,以及Java科学计数法的问题。
import java.math.*;import java.util.Scanner;public class Main {public static void main(String[] args) {// TODO Auto-generated method stub/*sss*/BigDecimal a, c, d;int b ;Scanner cin = new Scanner(System.in);while(cin.hasNext()){a = cin.nextBigDecimal();b = cin.nextInt();a = a.pow(b);String s;s = a.toPlainString(); //避免科学记数法(如果用a.toSting会存成科学记数法)int start = 0;while(s.charAt(start) == '0'){ //a.charAt(b) 取a字符串下标为b的字符start++;}int end = s.length()-1;while(s.charAt(end) == '0'){end--;}if(s.charAt(end) == '.'){end--;}for(int i = start; i <= end; ++i){System.out.print(s.charAt(i));}System.out.println();//System.out.println();//subtract-, add+, multiply* divide/ }cin.close();}}
0 0
- POJ 1001 Exponentiation(大数处理)
- poj 1001 Exponentiation(大数)
- POJ 1001 Exponentiation(大数)
- 【POJ】 1001 Exponentiation 大数
- poj 1001 -- Exponentiation (大数计算,模拟)
- POJ 1001 Exponentiation (高精度/大数乘法)
- Exponentiation(POJ-1001) Java大数例题
- [转]POJ 1001 Exponentiation Java大数处理高精度小数
- poj 1001 Exponentiation JAVA大数
- HDU 1063/POJ 1001-Exponentiation(大数类)
- poj 1001 Exponentiation 模拟大数(hdu 1063)
- HDU 1063 && POJ 1001 Exponentiation (JAVA浮点数大数)
- POJ 1001 Exponentiation(大数幂Java实现)
- POJ 1001 Exponentiation 大数乘法模拟
- POJ 1001 Exponentiation(java+处理字符串)
- POJ 1001-Exponentiation(NYOJ 155 求高精度幂):大数问题
- POJ 1001 Exponentiation 无限大数的指数乘法 题解
- HDU 1063Exponentiation(Java的大数处理)
- 理解矩阵二
- android之Can't create handler inside thread that has not called Looper.prepare()
- adjacent_find 查找相邻元素
- c++作为底层框架和lua进行打通
- CentOS6.3环境下openresty安装drizzle模块
- POJ 1001 Exponentiation(大数处理)
- PAT-1073. Scientific Notation(Java StringBuild)
- Linux学习(2014/3/13 )
- PAT系列索引
- mismatch,equal比较两序列
- FusionCharts多数据验证饼图label是否重叠
- oc门的设计思路
- PHP的header警告
- CareerCup An in-place algorithm for String Transformation