题目描述
四平方和
代码实现
package com.atguigu.TEST;import java.util.Scanner;class Main{public static void main(String[] args) {Scanner sc = new Scanner(System.in);int N=0;if (sc.hasNext()){N=sc.nextInt();}for (int a = 0; a < 2400; a++) {for (int b = a; b < 2400; b++) {for (int c = b; c < 2400; c++) {for (int d = c; d < 2400; d++) {if(a*a+b*b+c*c+d*d==N){ System.out.println(a+" "+b+" "+c+" "+d);return;}}}}}sc.close();}
}