#abc343c. C - 343

C - 343

Score: 250250 points

问题描述

给定一个正整数 NN

找出不大于 NN 的回文立方数中的最大值。

这里,一个正整数 KK 被定义为回文立方数,当且仅当它满足以下两个条件:

  • 存在一个正整数 xx,使得 x3=Kx^3 = K
  • 不带前导零的 KK 的十进制表示是一个回文。具体来说,如果 KK 表示为 K=i=0L1Ai10iK = \sum_{i = 0}^{L-1} A_i10^i,其中 A0,A1,,AL2A_0, A_1, \ldots, A_{L-2} 是介于 0099(包含)之间的整数,而整数 AL1A_{L-1} 介于 1199(包含)之间,则对于所有 i=0,1,,L1i = 0, 1, \ldots, L-1,都有 Ai=AL1iA_i = A_{L-1-i}

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

Problem Statement

You are given a positive integer NN.

Find the maximum value of a palindromic cube number not greater than NN.

Here, a positive integer KK is defined to be a palindromic cube number if and only if it satisfies the following two conditions:

  • There is a positive integer xx such that x3=Kx^3 = K.
  • The decimal representation of KK without leading zeros is a palindrome. More precisely, if KK is represented as K=i=0L1Ai10iK = \sum_{i = 0}^{L-1} A_i10^i using integers A0,A1,,AL2A_0, A_1, \ldots, A_{L-2} between 00 and 99, inclusive, and an integer AL1A_{L-1} between 11 and 99, inclusive, then Ai=AL1iA_i = A_{L-1-i} for all i=0,1,,L1i = 0, 1, \ldots, L-1.

Constraints

  • NN is a positive integer not greater than 101810^{18}.

Input

The input is given from Standard Input in the following format:

NN

Output

Print the answer.

Sample Input 1

345

Sample Output 1

343

343343 is a palindromic cube number, while 344344 and 345345 are not. Thus, the answer is 343343.

Sample Input 2

6

Sample Output 2

1

Sample Input 3

123456789012345

Sample Output 3

1334996994331

update @ 2024/3/10 01:15:50