zoukankan      html  css  js  c++  java
  • uva748

    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 有时判题不给结果,我擦。。。

  • 相关阅读:
    迷宫 广搜
    steam 字符串hash or map
    Karen与测试 奇迹淫巧+快速幂
    puzzle 期望树形DP
    函数 贪心
    P1032 字串变换 字符串
    等效集合 图论(缩点)
    高斯消元
    loj2537. 「PKUWC2018」Minimax
    loj2538. 「PKUWC2018」Slay the Spire
  • 原文地址:https://www.cnblogs.com/ya-cpp/p/4031934.html
Copyright © 2011-2022 走看看