Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
实在是没招了,大拿们帮忙看看吧!!!!!import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String args[]) throws Exception { BufferedReader stdin = new BufferedReader(new InputStreamReader(System. in)); String string; StringTokenizer st; BigDecimal p; BigDecimal result; int n; while (true) { result = new BigDecimal("1"); string = stdin.readLine(); if (string == null) { break; } st = new StringTokenizer(string); String temStr = st.nextToken(); p = new BigDecimal(temStr); n = Integer.parseInt(st.nextToken()); for (int i = 0; i < n; i++) { result = result.multiply(p); } String tem = result.toString(); int start = 0, end = tem.length() - 1; while (start<tem.length()&&tem.charAt(start) == '0') { start++; } int ends=0; while(ends<tem.length() && tem.charAt(ends)!='.') ends++; while (end>ends&&tem.charAt(end) == '0') { end--; } if (tem.substring(start, end + 1).equals("0")||tem.substring(start, end + 1).equals("")) { System.out.println("."); } else { System.out.println(tem.substring(start, end + 1)); } } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator