解题思路:java中的BigInteger类可以实现大型整数的乘法运算。
注意事项:测试案例中有0。
参考代码:
import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(); BigInteger bigInteger = new BigInteger("1"); for (int i = 1; i <= n; ++i) { bigInteger = bigInteger.multiply(BigInteger.valueOf(2)); } System.out.println(bigInteger); } }
0.0分
0 人评分