TopCoder problem "MatchCounting" used in SRM 239 (Division I Level Two)



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

0)
    
1
Returns: 1
1)
    
2
Returns: 2
2)
    
5
Returns: 6
3)
    
6
Returns: 8
4)
    
9
Returns: 20

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=3555

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=6538&pm=3555

Writer:

supernova

Testers:

PabloGilberto , lbackstrom , brett1479

Problem categories:

Simulation