Either way square

find how many pairs of integers ( x , y ) (x,y) satisfying 1 x 100 1 \leq x\leq 100 1 y 100 1 \leq y\leq 100 are there ,which satisfies following 2 condtions?

1) x y x-y is a perfect square.
2) x + y x+y is a perfect square.

For example, ( 5 , 4 ) (5,4) works since 5 4 = 1 2 5-4=1^2 and 5 + 4 = 3 2 5+4=3^2 .

Details and Assumptions :

0 0 is not a perfect square.


The answer is 31.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

4 solutions

Pablo Moran
Mar 30, 2014

There is an easy way to do it only with a piece of paper:

You write all the squares from 1 to 196 (anymore won't satisify x + y 200 x\quad +\quad y\quad \le \quad 200 So you have :

1 4 9 16 25 36 49 64 81 100 121 144 169 196

Then you start with x - y = 1

So (5,4) is a solution, (13,12) , (25,24),... quickly you see that only the odd squares satisfy the condition , that's because they are the solution to the system: { x y = 1 x + y = s q u a r e \begin{cases} x & - & y & = & 1 \\ x & + & y & = & square \end{cases} , where x = s q u a r e + 1 2 y = s q u a r e 1 2 x\quad =\frac { square\quad +\quad 1 }{ 2 } \\ y\quad =\frac { square\quad -\quad 1\quad }{ 2 }

For x - y = 4 , only the even squares satisfy the condition, for the same reason that above.

  • For x - y = 1, you get 6 solutions ( from 1, 9, 25,... to 169)
  • For x - y = 4, you get 6 solutions ( from 16 , 36, ... to 196)
  • For x - y = 9, you get 5 solutions ( from 25 to 196 )
  • For x - y = 16, you get 4 solutions ( from 36 to 144)
  • For x - y = 25, you get 4 solutions ( from 49 to 169)
  • For x - y = 36, you get 3 solutions (etc)
  • For x - y = 49, you get 2 solutions
  • For x - y = 64, you get 1 solutions
  • For x - y = 81, you get 0 solutions

It seems like a lot of work, but you can do it in 2 minutes, you just have to check the higher square so it doesn't surpass x + y <= 200

Adding up all the solutions, you get 31

Rohti Vaidya
Mar 29, 2014

int ps=0; for(int i=1;i<=100;i++) for(int j=1;j<=100;j++) { if(i!=j&&((Math.sqrt(i-j)-(int)(Math.sqrt(i-j))==0&&Math.sqrt(i+j)-(int)Math.sqrt(i+j)==0))) { ps++;System.out.println(i+" "+j); } } System.out.println("vvalue"+ps);

Kenny Lau
Sep 9, 2014

java code:

public class brilliant201409071548{
    public static void main(String[] args){
        int count = 0;
        for(int y=1;y<=100;y++){
            for(int x=y+1;x<=100;x++){
                if(Math.sqrt(x-y)-((int)(Math.sqrt(x-y)))==0&&Math.sqrt(x+y)-((int)(Math.sqrt(x+y)))==0){
                    count++;
                    System.out.println("("+x+","+y+")");
                }
            }
        }
        System.out.println(count);
    }
}

output:

(5,4)
(10,6)
(17,8)
(26,10)
(13,12)
(37,12)
(50,14)
(20,16)
(65,16)
(82,18)
(29,20)
(25,24)
(40,24)
(53,28)
(34,30)
(68,32)
(45,36)
(85,36)
(41,40)
(58,42)
(52,48)
(73,48)
(90,54)
(65,56)
(61,60)
(80,64)
(74,70)
(97,72)
(89,80)
(85,84)
(100,96)
31
Press any key to continue . . .

Mathematica Code:

1
2
3
4
5
isSq[n_] := Sqrt[n] == Floor[Sqrt[n]]
isSq[0] := False
F[{x_, y_}] := And[isSq[x + y] , isSq[x - y]]

Select[Subsets[Range[100], 2], F]

Outputs:

1
2
3
4
5
    {{4, 5}, {6, 10}, {8, 17}, {10, 26}, {12, 13}, {12, 37}, {14, 
  50}, {16, 20}, {16, 65}, {18, 82}, {20, 29}, {24, 25}, {24, 
  40}, {28, 53}, {30, 34}, {32, 68}, {36, 45}, {36, 85}, {40, 
  41}, {42, 58}, {48, 52}, {48, 73}, {54, 90}, {56, 65}, {60, 
  61}, {64, 80}, {70, 74}, {72, 97}, {80, 89}, {84, 85}, {96, 100}}

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...