#P10576. Finding the Sum of Special Integers on Children’s Day

    ID: 12597 Type: Default 1000ms 256MiB

Finding the Sum of Special Integers on Children’s Day

Finding the Sum of Special Integers on Children’s Day

On Children’s Day, Teacher Blue presents an interesting problem. Consider an integer n such that both n + 10120300500 and n - 10120300500 are perfect squares. A number is called a perfect square if it can be written as the square of an integer (for example, 4 = 2² and 9 = 3²). Your task is to compute the sum of all such integers n.

Formally, find the value of

$$S = \sum n, \text{ subject to } \begin{cases} n+10120300500 = a^2\\ n-10120300500 = b^2 \end{cases} $$

where a and b are non‐negative integers. Notice that subtracting the two equations gives:

a2b2=2×10120300500.a^2 - b^2 = 2\times10120300500.

This equation can be rewritten as

(ab)(a+b)=20240601000.(a-b)(a+b)=20240601000.

By setting a-b = 2x and a+b = 2y, we obtain xy = 10120300500/2 = 5060150250 with x,y positive integers. It turns out that all solutions are in one-to-one correspondence with the divisors of 750 (since the constant factors factor nicely as 5060150250 = 750 \times 6746867). In particular, if we let

$$d \in \{1,2,3,5,6,10,15,25,30,50,75,125,150,250,375,750\}, $$

then one may show that the general solution is

$$n = \Big(d + \frac{750}{d}\cdot 6746867\Big)^2 - 10120300500. $$

Your program should compute the sum of n over all 16 divisor‐pairs (each divisor d of 750 gives a unique solution).

inputFormat

This problem has no input.

outputFormat

Output a single integer — the sum of all integers n satisfying the given conditions.

sample

36965500000000000000