#P10373. [AHOI2024 初中组 / 科大国创杯初中组 2024] 立方根

    ID: 11771 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>数学递推2024安徽O2优化前缀和分块双指针 two-pointer

[AHOI2024 初中组 / 科大国创杯初中组 2024] 立方根

Background

The testdata for this problem is not official.

We are collecting official testdata (that can be uploaded here).

Official testdata (cannot be uploaded here): https://www.luogu.com.cn/training/499869

Unofficial testdata download: https://scg3.piaoztsdy.cn/training/69bce235a7cf509104565c83

Special notes:

  1. Please use (int) cbrt(x + 0.5) to compute x3\lfloor \sqrt[3]{x} \rfloor, otherwise precision errors may occur.
  2. This problem includes two hack test cases against algorithms with time complexity O(qx3)O(q\sqrt[3]{x}) (#11 and #12).

Problem Description

Xiaokeke wants to compute the sum of the floored cube roots of all positive integers not greater than xx, but she does not know how. Can you help her?

To fully help Xiaokeke understand this problem, you need to answer qq queries. For each query, given a positive integer xix_i, output:

$$\sum _{j=1} ^{x_i} \lfloor j^{\frac{1}{3}} \rfloor$$

Here, x\lfloor x \rfloor denotes the greatest integer not greater than xx.

Input Format

The first line contains a positive integer qq.

Then follow qq lines. The ii-th line contains a positive integer xix_i.

It is guaranteed that x1xq\bm{x_1 \sim x_q} is non-decreasing.

Output Format

Output qq lines. Each line contains a positive integer, representing the answer to that query.

Please pay attention to the range of the answer.

2
5
10
5
13

Hint

Sample 1 Explanation

The floored cube roots of 1101 \sim 10 are: 1,1,1,1,1,1,1,2,2,21,1,1,1,1,1,1,2,2,2.

Constraints

For 20%20\% of the data, xq,q1000x_q,q \le 1000.

For another 20%20\% of the data, q=1q=1.

For another 20%20\% of the data, q5000q \le 5000.

For another 20%20\% of the data, q105q \le 10^5, xq106x_q \le 10^6.

For 100%100\% of the data, 1q2×1051 \le q \le 2 \times 10^5, 1x1x2xq10121 \le x_1 \le x_2 \le \ldots \le x_q \le 10^{12}.

Translated by ChatGPT 5