2 shunfurh shunfurh 于 2017.01.01 09:55 提问

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

1个回答

devmiao
devmiao   Ds   Rxr 2017.01.03 18:43
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!