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

贴一份代码,感觉自己写的好搓,看来我注定是ds程序员的命

Posted by julianchen at 2014-09-21 11:16:35 on Problem 1001
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

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

}

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