102463: [AtCoder]ABC246 D - 2-variable Function

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

Given an integer $N$, find the smallest integer $X$ that satisfies all of the conditions below.

  • $X$ is greater than or equal to $N$.
  • There is a pair of non-negative integers $(a, b)$ such that $X=a^3+a^2b+ab^2+b^3$.

Constraints

  • $N$ is an integer.
  • $0 \le N \le 10^{18}$

Input

Input is given from Standard Input in the following format:

$N$

Output

Print the answer as an integer.


Sample Input 1

9

Sample Output 1

15

For any integer $X$ such that $9 \le X \le 14$, there is no $(a, b)$ that satisfies the condition in the statement.
For $X=15$, $(a,b)=(2,1)$ satisfies the condition.


Sample Input 2

0

Sample Output 2

0

$N$ itself may satisfy the condition.


Sample Input 3

999999999989449206

Sample Output 3

1000000000000000000

Input and output may not fit into a $32$-bit integer type.

Input

题意翻译

给定整数 $N$,请你找到最小的整数 $X$,满足: - $X \ge N$ - 存在一对非负整数 $(a, b)$,使得 $X = a^3 + a^2b + ab^2 + b^3$。

Output

分数:$400$分

问题描述

给定一个整数$N$,找到满足以下所有条件的最小整数$X$。

  • $X$大于等于$N$。
  • 存在一对非负整数$(a, b)$,使得$X=a^3+a^2b+ab^2+b^3$。

约束条件

  • $N$是一个整数。
  • $0 \le N \le 10^{18}$

输入

从标准输入按照以下格式获取输入:

$N$

输出

以整数形式打印答案。


样例输入1

9

样例输出1

15

对于满足$9 \le X \le 14$的任何整数$X$,不存在满足题目条件的$(a, b)$。
对于$X=15$,$(a,b)=(2,1)$满足条件。


样例输入2

0

样例输出2

0

$N$本身可能满足条件。


样例输入3

999999999989449206

样例输出3

1000000000000000000

输入和输出可能不适合$32$位整数类型。

加入题单

算法标签: