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

1001

Posted by cyl3392207 at 2006-06-27 19:37:31
In Reply To:我的程序都对的就是通不过啊 版主帮忙看看 Posted by:cyl3392207 at 2006-06-27 19:37:13
> import java.util.*;
> import java.io.*;
> import java.math.BigDecimal;
> public class Main{
>     public static BigDecimal exp(BigDecimal n,int p)throws IOException{
>           return n.pow(p);
>     }
>     public static void main(String [] args)throws IOException{
>     	BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
>     	String s;
>     	try{
>     	while(true){
> 	    	s=bf.readLine();
> 
> 	    	if(s.length()<3) 
> 	    	   System.exit(0);
> 	    	String[] strings= s.split(" ");
> 	    	String s1,s2;
> 	        s1=strings[0];
> 	        if(strings.length==2)
> 	        	s2=strings[1];
> 	        else s2=strings[2];
> 	    	BigDecimal big=new BigDecimal(s1);
> 	    	int pow=Integer.parseInt(s2);
> 	    
> 	    	BigDecimal result=exp(big.stripTrailingZeros(),pow);
> 	    	String de;
> 	    	if(result.compareTo(BigDecimal.ONE)<0){
> 	    		int index;
> 	   		    de=result.toString();
> 	
> 	    		if(de.contains("E")){
> 	    		    String[] ss2=de.split("E");
> 	    		    index= Integer.parseInt(ss2[1]);
> 	    		    System.out.print(".");
> 	    		    while(index<-1){
> 	    		    	System.out.print("0");
> 	    		    	index++;
> 	    		    }
> 	    		    System.out.print(de.charAt(0));
> 	    		   		 if(ss2[0].length()>1)
> 	    		       System.out.println(ss2[0].substring(2));
> 	    		       else{
> 	    		       	   System.out.println("");
> 	    		       }
> 	    		   
> 	    		}else{
> 	    			System.out.println(de.substring(1));
> 	    		}
> 	    	}else{
> 	    		System.out.println(result);
> 	    	}
> 	    }
> 	    }catch(Exception e){
> 	    }
>     	
>     	
>     }
> }

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