poj 1001 Exponentiation
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in =new Scanner(System.in);
while(in.hasNextBigDecimal())
{
BigDecimal ans=BigDecimal.ONE;
double a=in.nextDouble();
int b=in.nextInt();
int i=1;
for(i=1;i<=b;i++)
{
ans=ans.multiply(BigDecimal.valueOf(a));
}
ans=ans.stripTrailingZeros();
String s=ans.toPlainString();
char first=s.charAt(0);
if(first=='0')
{
System.out.println(s.substring(1, s.length()));
}
else
System.out.println(s);
}
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。http://xiang578.top/