请问最后一个点为啥显示Memory limit exceeded

dchdch edited 1 年,9 月前

import java.util.Scanner;
public class Main{
    public static void main (String[] args) {
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        //第n个1所在位置为(n-1)*n/2 +1
        for(;n>0;n--){
            int a=scan.nextInt();
            a=a-1;
            int sqr=(int)Math.sqrt(a*2.0);
            if(sqr*(sqr-1)/2==a||sqr*(sqr+1)/2==a) System.out.println("1");
            else System.out.println("0");
        }
        
    }
    
}

Comments