Statistics

Problem Statement for "MatchCounting"

Problem Statement

In order to sharpen their basic arithmetic skills, kids often try to represent numbers using match sticks. As one is only given a limited number, one student is curious how high he can count with his matches.

Each one digit number is represented as follows:
- number 8 uses seven matches.
- numbers 0, 6 and 9 each use six matches.
- numbers 2, 3 and 5 each use five matches.
- numbers 4 and 7 each use four matches.
- number 1 uses two matches.

Given an int n denoting the number of matches he has at his disposal, return the smallest positive integer that cannot be represented.

Definition

Class:
MatchCounting
Method:
count
Parameters:
int
Returns:
long
Method signature:
long count(int n)
(be sure your method is public)

Constraints

  • n is between 1 and 128, inclusive.

Examples

  1. 1

    Returns: 1

  2. 2

    Returns: 2

  3. 5

    Returns: 6

  4. 6

    Returns: 8

  5. 9

    Returns: 20

  6. 3

    Returns: 2

  7. 4

    Returns: 2

  8. 7

    Returns: 10

  9. 8

    Returns: 18

  10. 10

    Returns: 20

  11. 121

    Returns: 200888888888888888

  12. 122

    Returns: 208888888888888888

  13. 123

    Returns: 288888888888888888

  14. 124

    Returns: 688888888888888888

  15. 125

    Returns: 888888888888888888

  16. 126

    Returns: 1088888888888888888

  17. 127

    Returns: 1888888888888888888

  18. 128

    Returns: 2008888888888888888

  19. 15

    Returns: 188

  20. 16

    Returns: 200

  21. 18

    Returns: 288

  22. 21

    Returns: 1088

  23. 23

    Returns: 2008

  24. 25

    Returns: 2888

  25. 27

    Returns: 8888

  26. 31

    Returns: 20888

  27. 32

    Returns: 28888

  28. 33

    Returns: 68888

  29. 35

    Returns: 108888

  30. 36

    Returns: 188888

  31. 38

    Returns: 208888

  32. 42

    Returns: 1088888

  33. 50

    Returns: 18888888

  34. 52

    Returns: 20888888

  35. 55

    Returns: 88888888

  36. 58

    Returns: 200888888

  37. 59

    Returns: 208888888

  38. 61

    Returns: 688888888

  39. 67

    Returns: 2888888888

  40. 73

    Returns: 20888888888

  41. 77

    Returns: 108888888888

  42. 80

    Returns: 208888888888

  43. 85

    Returns: 1888888888888

  44. 91

    Returns: 10888888888888

  45. 93

    Returns: 20088888888888

  46. 100

    Returns: 200888888888888

  47. 101

    Returns: 208888888888888

  48. 112

    Returns: 10888888888888888

  49. 114

    Returns: 20088888888888888

  50. 117

    Returns: 68888888888888888

  51. 119

    Returns: 108888888888888888

  52. 128

    Returns: 2008888888888888888

  53. 127

    Returns: 1888888888888888888

  54. 125

    Returns: 888888888888888888

  55. 126

    Returns: 1088888888888888888

  56. 124

    Returns: 688888888888888888

  57. 100

    Returns: 200888888888888

  58. 7

    Returns: 10

  59. 97

    Returns: 88888888888888

  60. 8

    Returns: 18

  61. 47

    Returns: 6888888

  62. 14

    Returns: 108

  63. 43

    Returns: 1888888


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: