#P7127. 「RdOI R1」一次函数(function)

「RdOI R1」一次函数(function)

Description

Let SkS_k be the area of the triangle enclosed by the lines lk1:y=kx+k1l_{k1}:y=kx+k-1, lk2:y=(k+1)x+kl_{k2}:y=(k+1)x+k, and the xx-axis. Find:

i=1nSi\sum_{i=1}^nS_i

In this problem, there are tt queries in total. Each query gives nin_i, and you need to compute the value of the expression above when n=nin=n_i.

If n<1n<1, the value of the sum is considered to be 00.

Input Format

There are t+1t+1 lines in total.

The first line contains an integer tt, meaning there are tt sets of testdata.

The next tt lines each contain an integer nin_i, with the meaning as described in the statement.

Output Format

There are tt lines in total.

Each line contains one number, representing the answer you computed.

The result may be a fraction. Please reduce it to the simplest fraction. Output fractions in the form xxx/xxx. For example, 12\dfrac{1}{2} should be written as 1/2, and 24\dfrac{2}{4} should be written as 1/2. Note that you must reduce the fraction.

Note: If the answer is 00, output 0.

2
0
1
0
1/4

Hint

[Sample Explanation]

When n=0n=0, according to the statement, output 00.

When n=1n=1, S1S_1 is the area enclosed by y=xy=x, y=2x+1y=2x+1, and the xx-axis, which is 14\dfrac{1}{4}.


[Constraints]

  • For 5%5\% of the data, t100,n=0t \le 100,n=0.
  • For another 20%20\% of the data, t100,n2020t \le 100,n \le 2020.
  • For another 20%20\% of the data, t5×104,n5×103t \le 5 \times 10^4,n \le 5 \times 10^3.
  • For 100%100\% of the data, $1 \le t \le 2 \times 10^6,0 \le n \le 2 \times 10^6$.

[Notes / Hints]

  • It is recommended to draw a diagram and think about it.
  • Please remember to reduce the answer when outputting.
  • Please use a fast input method.

[File Input/Output] (Simulation, not needed in submitted code)

  • Filename: function.cpp.
  • Input filename: function.in.
  • Output filename: function.out.

Translated by ChatGPT 5