#abc246d. D - 2-variable Function

D - 2-variable Function

Score : 400400 points

问题描述

给定一个整数 NN,找出满足以下所有条件的最小整数 XX

  • XX 不小于 NN
  • 存在一对非负整数 (a,b)(a, b) 使得 X=a3+a2b+ab2+b3X=a^3+a^2b+ab^2+b^3

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Given an integer NN, find the smallest integer XX that satisfies all of the conditions below.

  • XX is greater than or equal to NN.
  • There is a pair of non-negative integers (a,b)(a, b) such that X=a3+a2b+ab2+b3X=a^3+a^2b+ab^2+b^3.

Constraints

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

Input

Input is given from Standard Input in the following format:

NN

Output

Print the answer as an integer.

Sample Input 1

9

Sample Output 1

15

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

Sample Input 2

0

Sample Output 2

0

NN itself may satisfy the condition.

Sample Input 3

999999999989449206

Sample Output 3

1000000000000000000

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

update @ 2024/3/10 10:33:24