CodeBus
www.codebus.net
Search
Sign in
Sign up
Hot Search :
Source
embeded
web
remote control
p2p
game
More...
Location :
Home
Search - squaredigits
Main Category
SourceCode
Documents
Books
WEB Code
Develop Tools
Other resource
Search - squaredigits - List
[
Communication-Mobile
]
SquareDigits
DL : 0
自己写的topcoder大赛源码,可以作为练习参考
Date
: 2008-10-13
Size
: 1.66kb
User
:
高倩文
[
Communication-Mobile
]
SquareDigits
DL : 0
自己写的topcoder大赛源码,可以作为练习参考-Write their own source of TopCoder Competition can be used as a reference to practice
Date
: 2025-07-04
Size
: 1kb
User
:
高倩文
[
JSP/Java
]
SquareDigits
DL : 0
SquareDigits的算法简单实现,SquareDigits是topcoder的一个问题- Problem Statement ***Note: Please keep programs under 7000 characters in length. Thank you Class Name: SquareDigits Method Name: smallestResult Parameters: int Returns: int Define the function S(x) as the sum of the squares of the digits of x. For example: S(3)=3*3=9 and S(230)=2*2+3*3+0*0=13. Define the set T(x) to be the set of unique numbers that are produced by repeatedly applying S to x. That is: S(x), S(S(x)), S(S(S(x))), etc... For example, repeatedly applying S to 37: S(37)=3*3+7*7=58. S(58)=5*5+8*8=89. S(89)=145. S(145)=42. S(42)=20. S(20)=4. S(4)=16. S(16)=37. Note this sequence will repeat so we can stop calculating now and: T(37)={58,89,145,42,20,4,16,37}. However, note T(x) may not necessarily contain x. Implement a class SquareDigits, which contains a method smallestResult. The method takes an int, n, as a parameter and returns the smallest int, x, such that T(x) contains n. The method signatu
Date
: 2025-07-04
Size
: 1kb
User
:
姜水烈山
[
Windows Develop
]
correct_SquareDigits
DL : 0
网上很多是错的 Define the function S(x) as the sum of the squares of the digits of x. For example: S(3)=3*3=9 and S(230)=2*2+3*3+0*0=13. Define the set T(x) to be the set of unique numbers that are produced by repeatedly applying S to x. That is: S(x), S(S(x)), S(S(S(x))), etc... For example, repeatedly applying S to 37: -Class Name: SquareDigits Method Name: smallestResult Parameters: int Returns: int Define the function S(x) as the sum of the squares of the digits of x. For example: S(3)=3*3=9 and S(230)=2*2+3*3+0*0=13. Define the set T(x) to be the set of unique numbers that are produced by repeatedly applying S to x. That is: S(x), S(S(x)), S(S(S(x))), etc... For example, repeatedly applying S to 37: S(37)=3*3+7*7=58. S(58)=5*5+8*8=89. S(89)=145. S(145)=42. S(42)=20. S(20)=4. S(4)=16. S(16)=37. Note this sequence will repeat so we can stop calculating now and: T(37)={58,89,145,42,20,4,16,37}. However, note T(x) may not necessarily contain x. Implement a class SquareDigits, which contains a method smallestResult. The method takes an int, n, as a parameter and returns the smallest int, x, such that T(x) contains n. The method signature is (be sure your method is public): int smallestResult(int n) TopCoder will ensure n is non-negative and is between 0
Date
: 2025-07-04
Size
: 1kb
User
:
trastain
[
Other
]
TopCoder_02
DL : 0
实现topcoder上的例题!实现了SquareDigits类,大家可以参考-implement of topcoder
Date
: 2025-07-04
Size
: 1kb
User
:
余道明
CodeBus
is one of the largest source code repositories on the Internet!
Contact us :
1999-2046
CodeBus
All Rights Reserved.