zoukankan      html  css  js  c++  java
  • 计算99的99次幂

    package japan.example.test;
    
    import java.math.BigDecimal;
    import java.math.BigInteger;
    import java.text.DecimalFormat;
    
    public class Nine9Test {
    
        public static void main(String[] args) {
    
            double d = Math.pow(100, 100);
            System.err.println(d);
    
            Nine9Test test = new Nine9Test();
            BigInteger f = test.test(new BigInteger("100001"), 1000);
    
            BigDecimal b = new BigDecimal(f);
            DecimalFormat df = new DecimalFormat("#.#####E0");
            df.setMinimumFractionDigits(2);
            df.setMaximumFractionDigits(2);
            String display = df.format(b);
            System.err.println(display);
        }
    
        @Deprecated
        public double test(double d, int p) {
            double r = 1.0d;
            for (int i = 0; i < p; i++) {
                r *= d;
            }
    
            return r;
        }
    
        public BigInteger test(BigInteger d, int p) {
            BigInteger r = new BigInteger("1");
            for (int i = 0; i < p; i++) {
                r = r.multiply(d);
            }
    
            return r;
        }
    }
  • 相关阅读:
    Codeforces 1132D
    Codeforces 670F
    Codeforces 670E
    Codeforces 670E
    Codeforces 670E
    Codeforces 670
    Codeforces 1138
    Codeforces 1114E
    力扣21.合并两个有序链表
    力扣538.把二叉树转换为累加树
  • 原文地址:https://www.cnblogs.com/jpit/p/8444123.html
Copyright © 2011-2022 走看看