Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
贴代码import java.math.BigDecimal; import java.util.Scanner; public class Main { private Scanner scanner; private BigDecimal bigDecimal; private int n; public Main(){ scanner = new Scanner(System.in); } public void calculate(){ while(scanner.hasNext()){ bigDecimal = scanner.nextBigDecimal(); n = scanner.nextInt(); bigDecimal = bigDecimal.pow(n); String output = bigDecimal.toPlainString(); if (output.contains(".")){ int x = 0, y = output.length() - 1; while (output.charAt(x) == '0') x++; while (output.charAt(y) == '0') y--; if (output.charAt(y) != '.') y++; output = output.substring(x, y); } System.out.println(output); } } public static void main(String[] args) { Main exponentiation = new Main(); exponentiation.calculate(); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator