程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> lines-The Cubic End

lines-The Cubic End

編輯:編程解疑
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

最佳回答:


http://www.acmerblog.com/POJ-2847-The-Cubic-End-blog-885.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved