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 |
Java之中的float和double都不是精确的类型,读入的时候需要作为String读入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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator