| ||||||||||
| 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 | |||||||||
Re:这样写感觉完全没问题啊,但是就是不让过。。。。。In Reply To:这样写感觉完全没问题啊,但是就是不让过。。。。。 Posted by:724997498 at 2014-07-20 00:04:55 > import java.util.*;
> import java.math.*;
> public class Main {
> public static void main(String args[])
> {
> Scanner in=new Scanner(System.in);
> while(in.hasNext())
> {
> double a=cin.nextDouble();
> int b=cin.nextInt();
> BigDecimal num = new BigDecimal(a);
> BigDecimal result=num.pow(b);
> if(result.compareTo(result.setScale(0,BigDecimal.ROUND_FLOOR)) == 0) {
> System.out.println(result.setScale(0, BigDecimal.ROUND_FLOOR));
> }
> else if(result.compareTo(BigDecimal.ONE) == -1){
> String s = result.toPlainString();
> System.out.println(s.replaceFirst("^0*", ""));
> }
> else {
> System.out.println(result.toPlainString());
> }
> }
> }
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator