Java求救,给关注!爆内存了!
查看原帖
Java求救,给关注!爆内存了!
1406815
xiaobu321楼主2024/11/12 17:37

Java求救,给关注!爆内存了!

import java.math.BigInteger;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long p = scanner.nextLong();

        BigInteger bigInteger = new BigInteger("2");
        bigInteger=bigInteger.pow((int) p);
        bigInteger=bigInteger.add(new BigInteger("-1"));


        //进行格式化输出
        char[] value = bigInteger.toString().toCharArray();
        int length = value.length;
        System.out.println(length);
        int count=500;
        for (int i = 1; i <= 10*50; i++) {
            if (length-count>=0){
                System.out.print(value[length-count]);
            }else {
                System.out.print("0");
            }
            count--;
            if (i%50==0){
                System.out.println();
            }
        }
    }

}

2024/11/12 17:37
加载中...