当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2847:The Cubic End

题目描述

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 1000. 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.

输入样例
4
123
1234567
435621
9876543213
输出样例
947
2835223
786941
2916344917

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Greater New York 2005

源链接: POJ-2847

最后修改于 2020-10-29T06:45:42+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536