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

完全满足输入和输出,不知道为何不行,难道还有别的测试数据吗

Posted by julianchen at 2014-09-21 10:49:58
import java.math.BigDecimal;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		double []a = new double [6];
		int [] n =new int [6];
		Scanner cin=new Scanner(System.in);
		for(int i = 0; i<6;i++){
		
         a[i]=cin.nextDouble();
        	 n[i]	=cin.nextInt();
        	
		}
		for(int i =0;i<6;i++)
		{
			doJob(a,n,i);
		}
		
	}
	private static void doJob(double [] a,int[] n,int j)
	{
		BigDecimal x= new BigDecimal(String.valueOf(a[j]));
		//x.setScale(100);
		BigDecimal  sum=new BigDecimal("1");
		for(int i = 1; i<=n[j];i++)
		{
			sum = sum.multiply(x);
		}
		String output = sum.stripTrailingZeros().toPlainString();
		if(output.startsWith("0"))
		{
			output = output.substring(1);
		}
		
		
		System.out.println(output);
	}

}

95.123 12
0.4321 20
5.1234 15
6.7592  9
98.999 10
1.0100 12
548815620517731830194541.899025343415715973535967221869852721
.00000005148554641076956121994511276767154838481760200726351203835429763013462401
43992025569.928573701266488041146654993318703707511666295476720493953024
29448126.764121021618164430206909037173276672
90429072743629540498.107596019456651774561044010001
1.126825030131969720661201


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