CUBEND - Suffix Of Cube

题意翻译

### 题目描述 给定一个以 $1,3,7$ 或 $9$ 结尾的字符串,需要找到一个小于或等于字符串长度的数字,当这个数字立方后,其整数部分能以原字符串结尾。 ### 输入格式 输入的第一行是一个整数 $n$,表示问题实例的数量,$1\le n\le100$。接下来 $n$ 行,每行包含一个长度在 $1$ 到 $10$ 之间的字符串,以 $1,3,7$ 或 $9$ 结尾。 ### 输出格式 对于每个问题,输出一行,包含一个数字,该数字的立方能以给定的字符串结尾。输出的数字没有前导零。 如果存在多个答案,应选择最小的数字。 由 @[Yangbowen0108](https://www.luogu.com.cn/user/702258) 提供翻译

题目描述

Given any string of decimal digits, ending in 1, 3, 7 or 9, there is always a decimal number, which when cubed has a decimal expansion ending in the original given digit string. The number need never have more digits than the given digit string. Write a program, which takes as input a string of decimal digits ending in 1, 3, 7 or 9 and finds a number of at most the same number of digits, which when cubed, ends in the given digit string.

输入输出格式

输入格式


The input begins with a line containing only the count of problem instances, nProb, as a decimal integer, 1 <= nProb <= 100. This is followed by nProb lines, each of which contains a string of between 1 and 10 decimal digits ending in 1, 3, 7 or 9.

输出格式


For each problem instance, there should be one line of output consisting of the number, which when cubed, ends in the given digit string. The number should be output as a decimal integer with no leading spaces and no leading zeroes. If there are many answers, the minimum should be chosen.

输入输出样例

输入样例 #1

4 \n123 \n1234567 \n435621 \n9876543213

输出样例 #1

947 \n2835223 \n786941 \n2916344917