| ||||||||||
| 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 | |||||||||
为什么编译通不过,自己机子上通过的(1001)import java.math.*;
import java.util.*;
public class ACM1001 {
/**
* @param args
*/
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
String s = cin.nextLine();
int x;
if(s.charAt(7)==' '){
x = Integer.parseInt(s.substring(8,9));
}else{
x = Integer.parseInt(s.substring(7, 9));
}
BigInteger result = new BigInteger("1");
//System.out.println(x);
int i = s.indexOf(".");
if(i == -1){
BigInteger num = new BigInteger(s.substring(0, 6));
for(int j = 0;j<x;j++){
result = result.multiply(num);
}
System.out.println(result);
}else{
BigInteger num = new BigInteger(s.substring(0,i)+s.substring(i+1,6));
for(int j = 0;j<x;j++){
result = result.multiply(num);
}
String tempStr = String.valueOf(result);
if((5-i)*x==tempStr.length()){
System.out.println("."+tempStr);
}
if((5-i)*x>tempStr.length()){
String str = ".";
for(int m = 0;m<(5-i)*x-tempStr.length();m++){
str = str+"0";
}
System.out.println(str+tempStr);
}
if((5-i)*x<tempStr.length()){
System.out.println(tempStr.substring(0, tempStr.length()-(5-i)*x)+"."+tempStr.substring(tempStr.length()-(5-i)*x, tempStr.length()));
}
}
// TODO Auto-generated method stub
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator