标准的大数问题,第一次用Java的BigDecimal,感觉就是爽……
POJ1001
/*
8700416 MDK 1001 Accepted 3196K 172MS Java 601B 2011-05-28 20:34:03
*/
import java.io.BufferedInputStream;
import java.math.BigDecimal;
import java.util.Scanner;
class Test {
public static void main(String[] args)
{
Scanner cin=new Scanner(new BufferedInputStream(System.in));
while(cin.hasNext())
{
String a=cin.next();
int n=cin.nextInt();
BigDecimal bigIntt=new BigDecimal(a.trim());
bigIntt=bigIntt.pow(n);
//System.out.println(bigIntt);
bigIntt = bigIntt.stripTrailingZeros();
String result = bigIntt.toPlainString();
if(result.startsWith("0."))
result=result.substring(1);
System.out.println(result);
}
}
}
但是怎么都有种罪过感……
经测试:
Scanner cin=new Scanner(new BufferedInputStream(System.in));
buffer类比直接的system.in快12.4%。