QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#24389. 平方與立方

Statistics

某所大學的數論實驗室正在研究正整數的平方與立方的分布之間的關係。

給定一個非負整數 $k$。考慮從 $a$ 到 $b$(含兩端)的正整數集合。該集合的 $k$-密度定義為滿足 $a \le x^2 \le b$、$a \le y^3 \le b$ 且 $|x^2-y^3| \le k$ 的正整數對 $(x,y)$ 的數量。

例如,從 $1$ 到 $30$ 的正整數集合的 $2$-密度等於 $3$,因為以下數對符合條件:

  • $x=1$, $y=1$, $|x^2-y^3|=|1-1|=0$;

  • $x=3$, $y=2$, $|x^2-y^3|=|9-8|=1$;

  • $x=5$, $y=3$, $|x^2-y^3|=|25-27|=2$.

請編寫程式,根據給定的正整數 $a$、$b$ 和非負整數 $k$,求出從 $a$ 到 $b$(含兩端)的正整數集合的 $k$-密度。

輸入格式

輸入包含三行。第一行包含正整數 $a$,第二行包含正整數 $b$,第三行包含非負整數 $k$($1 \le a \le b \le 10^{18}$,$0 \le k \le 10^{18}$)。

輸出格式

輸出一個整數:從 $a$ 到 $b$(含兩端)的正整數集合的 $k$-密度。

範例

輸入格式 1

1
30
2

輸出格式 1

3

子任務

只有通過某個子任務及其所依賴的子任務的所有測試,才能獲得該子任務的分數。

子任務 分數 附加限制:$a,b$ 附加限制:$k$ 依賴子任務 回饋資訊
1 10 $1 \le a \le b \le 1000$ $k=0$ 完整
2 10 $1 \le a \le b \le 10^{18}$ $k=0$ 1 完整
3 15 $1 \le a \le b \le 1000$ $0 \le k \le 10$ 1 完整
4 15 $1 \le a \le b \le 10^6$ $0 \le k \le 10$ 1, 3 完整
5 15 $1 \le a \le b \le 10^9$ $0 \le k \le 10$ 1, 3, 4 完整
6 15 $1 \le a \le b \le 10^9$ $0 \le k \le 10^9$ 1, 3, 4, 5 完整
7 20 $1 \le a \le b \le 10^{18}$ $0 \le k \le 10^{18}$ 1–6 完整

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.