问题描述:

HD-ACM算法专攻系列(11)——Exponentiation

HD-ACM算法专攻系列(11)——Exponentiation

 

 

源码:

考察对大数的计算,需要注意去除前导0与后导0.

import java.math.BigDecimal;
import java.util.*;

public class Main
{
		//主函数
        public static void main(String[] args)
        {
            BigDecimal r;
			int n;
			String str;
			Scanner cin = new Scanner(System.in);
			while(cin.hasNext())
			{
				r = cin.nextBigDecimal();
				n = cin.nextInt();
				str = r.pow(n).stripTrailingZeros().toPlainString();
				if(str.charAt(0) == '0')str  = str.substring(1);
				System.out.println(str);
			}
		}
}
 

  

 

相关文章:

  • 2021-12-25
  • 2021-06-12
  • 2021-09-10
  • 2021-10-25
  • 2021-06-17
  • 2021-12-28
  • 2021-12-28
  • 2021-07-03
猜你喜欢
  • 2021-11-14
  • 2021-12-30
  • 2022-01-17
  • 2021-06-20
  • 2022-01-27
  • 2021-10-29
  • 2021-07-01
相关资源
相似解决方案