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 |
Java 太帅了!!!import java.math.BigDecimal; import java.util.Scanner; public class Main { public static void main(String[] args) { BigDecimal s; int n; Scanner cin=new Scanner(System.in); while(cin.hasNextBigDecimal()){ s=cin.nextBigDecimal(); n=cin.nextInt(); //System.out.println(s.pow(n)); BigDecimal ans=s.pow(n); String src=ans.toPlainString(); int i=0; int j=src.length(); if(src.indexOf('.')!=-1){ if(src.charAt(0)=='0'){ i=1; } for( j=src.length()-1;j>=0;j--){ if(src.charAt(j)=='0')continue; break; } j++; } if(src.charAt(j-1)=='.'){ j--; } System.out.println(src.substring(i,j)); } } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator