蓝桥杯2019国赛第一题

1、2019<X<Y
2、2019^2, X^2, Y^2构成等差数列
满足条件的X和Y可能有多种情况,请给出X+Y的值,并且令X+Y尽可能的小。

public class Main {
    
    
	
	public static void main(String[] args) {
    
    
		int n = 2019, N = 100000;
		for (int x = n + 1; x < N; x++) {
    
    
			for (int y = x + 1; y < N; y++) {
    
    
				if (y * y -  x * x == x * x - n * n) {
    
    
					//System.out.println(x + " " + y);
					System.out.println(x + y);
					return ;
				}
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/QinLaoDeMaChu/article/details/109598188