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

Re:Java太威武了,我是来贴代码的

Posted by 569894874 at 2012-12-14 16:43:46 on Problem 1001
In Reply To:Java太威武了,我是来贴代码的 Posted by:speedcell4 at 2011-08-26 15:03:05
> import java.io.PrintWriter;
> import java.math.BigDecimal;
> 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) 
> 	{
> 		BigDecimal a,c;
> 		int b;
> 		while (cin.hasNext()) 
> 		{
> 			a = cin.nextBigDecimal();
> 			b = cin.nextInt();
> 			c = a.pow(b);
> 			String ans = c.toPlainString();
> 			if (ans.contains(".") == false) 
> 			{
> 				cout.println(ans);
> 			} 
> 			else 
> 			{
> 				int x = 0, y = ans.length() - 1;
> 				while (ans.charAt(x) == '0') x++;
> 				while (ans.charAt(y) == '0') y--;
> 				if (ans.charAt(y) != '.') y++;
> 				cout.println(ans.substring(x, y));
> 			}
> 
> 		}
> 	}
> }

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