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 VincentQian at 2010-05-30 23:32:03
import java.math.*;
import java.util.*;
public class ACM1001 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin  = new Scanner(System.in);
		String s = cin.nextLine();
		int x;
		if(s.charAt(7)==' '){
			x = Integer.parseInt(s.substring(8,9));
		}else{
		  x = Integer.parseInt(s.substring(7, 9));
		}
		
		BigInteger result = new BigInteger("1");
		//System.out.println(x);
		int i  = s.indexOf(".");
		if(i == -1){
			BigInteger num = new BigInteger(s.substring(0, 6));
			for(int j = 0;j<x;j++){
				result = result.multiply(num);
			}
			System.out.println(result);
		}else{
			BigInteger num = new BigInteger(s.substring(0,i)+s.substring(i+1,6));
			for(int j = 0;j<x;j++){
				result = result.multiply(num);
			}
			String tempStr = String.valueOf(result);
			if((5-i)*x==tempStr.length()){
				System.out.println("."+tempStr);
			}
			if((5-i)*x>tempStr.length()){
				String str = ".";
				for(int m = 0;m<(5-i)*x-tempStr.length();m++){
					str = str+"0";
				}
				System.out.println(str+tempStr);
			}
			if((5-i)*x<tempStr.length()){
				System.out.println(tempStr.substring(0, tempStr.length()-(5-i)*x)+"."+tempStr.substring(tempStr.length()-(5-i)*x, tempStr.length()));
			}
		}
		// TODO Auto-generated method stub

	} 

}

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