Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

贴代码

Posted by dengyuzhong at 2014-09-25 17:55:19 on Problem 1001
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator