Statistics

Problem Statement for "RabbitNumber"

Problem Statement

When cat Taro and rabbit Hanako were practicing hard for SRM 484, they noticed an interesting property of 484. They called it Rabbit Number.

Let S(n) be the sum of the digits of n. For example, S(484) = 4+8+4 = 16 and S(22) = 2+2 = 4. A positive integer x is called a Rabbit Number if S(x*x) = S(x)*S(x). For example, 22 is a Rabbit Number because S(484) = S(22)*S(22).

Return the number of Rabbit Numbers between low and high, inclusive.

Definition

Class:
RabbitNumber
Method:
theCount
Parameters:
int, int
Returns:
int
Method signature:
int theCount(int low, int high)
(be sure your method is public)

Constraints

  • low will be between 1 and 1,000,000,000, inclusive.
  • high will be between low and 1,000,000,000, inclusive.

Examples

  1. 22

    22

    Returns: 1

    22 is a Rabbit Number because S(22*22) = S(484) = 16 S(22) * S(22) = 4 * 4 = 16

  2. 484

    484

    Returns: 0

    484 is not a Rabbit Number because S(484*484) = S(234256) = 22 S(484) * S(484) = 16 * 16 = 256

  3. 1

    58

    Returns: 12

  4. 58

    484

    Returns: 24

  5. 1000000000

    1000000000

    Returns: 1

  6. 1

    1000000000

    Returns: 7116

  7. 3

    9

    Returns: 1

  8. 2

    8

    Returns: 2

  9. 38

    54

    Returns: 0

  10. 7

    16

    Returns: 4

  11. 626

    985

    Returns: 0

  12. 647

    678

    Returns: 0

  13. 4366

    8445

    Returns: 0

  14. 6797

    9409

    Returns: 0

  15. 70762

    72091

    Returns: 0

  16. 31189

    97205

    Returns: 0

  17. 541304

    836723

    Returns: 0

  18. 287737

    304686

    Returns: 16

  19. 224156

    7766061

    Returns: 850

  20. 1794191

    2493164

    Returns: 254

  21. 55997858

    84272705

    Returns: 0

  22. 6229956

    70256053

    Returns: 1810

  23. 528330885

    791733587

    Returns: 0

  24. 88453870

    552998244

    Returns: 3872

  25. 1

    1

    Returns: 1

  26. 200122010

    200122010

    Returns: 1

  27. 1211101

    1211101

    Returns: 1

  28. 101010021

    101010021

    Returns: 1

  29. 21210110

    21210110

    Returns: 1

  30. 10002012

    10002012

    Returns: 1

  31. 220010001

    220010001

    Returns: 1

  32. 2000110

    2000110

    Returns: 1

  33. 1113000

    1113000

    Returns: 1

  34. 101021101

    101021101

    Returns: 1

  35. 111011

    111011

    Returns: 1

  36. 1

    999999999

    Returns: 7115

  37. 10

    999999999

    Returns: 7112

  38. 30010010

    1000000000

    Returns: 3970

  39. 3

    1000000000

    Returns: 7114

  40. 9

    999999993

    Returns: 7112

  41. 2

    1000000000

    Returns: 7115

  42. 2

    999999999

    Returns: 7114

  43. 1

    100000000

    Returns: 3244

  44. 12

    10000000

    Returns: 1429

  45. 1

    1000000

    Returns: 615

  46. 1

    199999999

    Returns: 5766

  47. 4

    1000000000

    Returns: 7113

  48. 155

    5345

    Returns: 75


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: