第二题:将公式转换成n/2a-a/2=x(1)。然后a从sqrt(n)开始递减。等式(1)成立时输出x。代码如下
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner complexScanIn = new Scanner(System.in);
        int T=complexScanIn.nextInt();
        if(T<=0||T>=1000) return;
        long n=0;
        for(int i=0;i<T;i++) {
            n=complexScanIn.nextLong();
            if(n<1L||n>1000000000L) return;
            
            //x<=n/2, x>1
            double a =Math.sqrt(n);
            double b = Math.floor(a);
            int j=(int)b;
            for(j=(int)b;j>0;j--) {
                double temp=n/(double)(2*j)-j/2.0;
                if(temp>0&&Math.floor(temp)==temp) {
                    System.out.println((int)Math.floor(temp));
                    break;
                }
            }
            if(j<=0)System.out.println(-1);
            
        }
    }