#P7779. 『JROI-2 / Stoi2039』等你下课

『JROI-2 / Stoi2039』等你下课

Description

Given a positive integer dd, define

$$S_v=\{(x,y):x,y \in \mathbb{Z_{\ge 0}},x^2-dy^2=v\}$$

Compute:

$$\sum_{v=1}^{\lfloor\sqrt{d}\rfloor}v[S_v \neq \varnothing]$$

There are multiple queries.

Input Format

The first line contains a positive integer tt, which indicates the number of queries.

The next tt lines each contain a positive integer dd, representing one query.

Output Format

For each query, output one line containing one integer, which is the answer.

4
10
13
16
19

1
4
5
5

Hint

Sample Explanation

  • For d=10d=10, only v=1v=1 satisfies SvS_v \neq \varnothing.
  • For d=13d=13, v=1,3v=1,3 satisfy SvS_v \neq \varnothing.
  • For d=16d=16, v=1,4v=1,4 satisfy SvS_v \neq \varnothing.
  • For d=19d=19, v=1,4v=1,4 satisfy SvS_v \neq \varnothing.

Constraints

  • For 30%30\% of the testdata, t=1t=1, 1d701 \le d \le 70.
  • For 60%60\% of the testdata, t=1t=1.
  • For 100%100\% of the testdata, 1t4×1031 \le t \le 4 \times 10^3, 1d2×1061 \le d \le 2 \times 10^6.

Source: JROI-2 Summer Fun Round - T4.

Idea & Solution & Standard & Data: VinstaG173.

Retest: None.

Translated by ChatGPT 5