QOJ.ac

QOJ

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

#24389. Squares and Cubes

Statistics

A university number theory laboratory is studying the relationship between the distribution of squares and cubes of positive integers.

Let $k$ be a nonnegative integer. Consider the set of positive integers from $a$ to $b$, inclusive. Its $k$-density is the number of pairs of positive integers $x$ and $y$ such that $a \le x^2 \le b$, $a \le y^3 \le b$, and $|x^2-y^3| \le k$.

For example, the $2$-density of the set of positive integers from $1$ to $30$ is $3$, since the following pairs qualify:

  • $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$.

Write a program that, given positive integers $a$ and $b$ and a nonnegative integer $k$, determines the $k$-density of the set of positive integers from $a$ to $b$, inclusive.

Input

The input contains three lines. The first line contains the positive integer $a$, the second contains the positive integer $b$, and the third contains the nonnegative integer $k$ ($1 \le a \le b \le 10^{18}$, $0 \le k \le 10^{18}$).

Output

Output one integer: the required $k$-density of the set of positive integers from $a$ to $b$, inclusive.

Examples

Input 1

1
30
2

Output 1

3

Subtasks

Points for a subtask are awarded only if all tests of that subtask and its prerequisite subtasks are passed.

Subtask Points Additional constraints: $a,b$ Additional constraints: $k$ Prerequisite subtasks Feedback
1 10 $1 \le a \le b \le 1000$ $k=0$ full
2 10 $1 \le a \le b \le 10^{18}$ $k=0$ 1 full
3 15 $1 \le a \le b \le 1000$ $0 \le k \le 10$ 1 full
4 15 $1 \le a \le b \le 10^6$ $0 \le k \le 10$ 1, 3 full
5 15 $1 \le a \le b \le 10^9$ $0 \le k \le 10$ 1, 3, 4 full
6 15 $1 \le a \le b \le 10^9$ $0 \le k \le 10^9$ 1, 3, 4, 5 full
7 20 $1 \le a \le b \le 10^{18}$ $0 \le k \le 10^{18}$ 1–6 full

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.