java 70内存爆了
查看原帖
java 70内存爆了
1564073
cccdd1楼主2024/11/22 20:32
import java.math.BigInteger;
import java.util.Scanner;

public class mai {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigInteger bg = new BigInteger("2");
        BigInteger res = new BigInteger("1");
        while (n != 1) {
            if (n % 2 == 1) {
                res = res.multiply(bg);
            }
            bg = bg.multiply(bg);
            n /= 2;
        }
        bg = bg.multiply(res);
        bg = bg.subtract(BigInteger.ONE);
        StringBuilder str = new StringBuilder(bg.toString());
        System.out.println(str.length());
        int m=-str.length()+500;
            for (int i = 0; i < 500; i++) {
                if(i%50==0&&i!=0) {
                    System.out.println();
                }
                if(i<m){
                    System.out.print("0");
                }
                else {
                    System.out.print(str.charAt(i-m));
                }
            }

            sc.close();
    }
}
2024/11/22 20:32
加载中...