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

Java之中的float和double都不是精确的类型,读入的时候需要作为String读入

Posted by Aimy at 2006-07-27 17:17:43 on Problem 1001
In Reply To:为什么是WA?到底是那里错了?莫非是编译器和JAVA过不去? Posted by:daryl at 2006-07-26 17:54:37
> import java.math.BigDecimal;
> import java.util.Scanner;
> 
> public class Main {
> 	double r=0;
> 	int n=0;
> 
> 	public Main() {
> 		Scanner cin = new Scanner(System.in);
> 			while(cin.hasNext()){
> 			r=cin.nextDouble();
> 			n=cin.nextInt();
> 			BigDecimal bigr=BigDecimal.valueOf(r);
> 			bigr=bigr.pow(n);
> 			String output=bigr.toPlainString();
> 			if(output.startsWith("0"))
> 				output=output.substring(1);
> 			System.out.println(output);
> 		}
> 	}
> 
> 	public static void main(String[] args) {
> 		Main m = new Main();
> 	}
> }
> 

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