Answer: 35
Solution:
First, I drew a diagram illustrating the problem.
Note, this diagram isn't necessarily to scale, because I don't know
how big x is to begin with.
Let s be the length of each side of square S.
Let the square be ABCD, so AP=7, BP=35, CP=49, and DP=x.
Drop altitudes from P to each side of S, and label the points as follows:
E is on AB, F is on BC, G is on CD, and H is on DA.
Label the lengths of the segments as follows:
EP, AH, and BF have length a; GP, DH, and CF have length s-a
FP, BE, and CG have length b; HP, AE, and DG have length s-b
By the Pythagorean Theorem, we have
EPB: a²+b²=35²
FPC: (s-a)²+b²=49²
EPA: a²+(s-b)² =7²
DPH: (s-a)²+(s-b)²=x²
By subtracting the first and fourth of these equations from the sum of the second and third, we get
0 = 49² + 7² - 35² - x², or
x² = 49² + 7² - 35²
x² = 35²
x = 35
Since DP and BP are equal, it follows that P is on the diagonal AC, so
the diagram is just a little misleading (which is why I didn't include it
in the original statement of the problem).