Connection Status:
Competition Arena > MatchCounting
SRM 239 · 2005-04-18 · by supernova · Simulation
Class Name: MatchCounting
Return Type: long
Method Name: count
Arg Types: (int)
Problem Statement

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.

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

Submissions are judged against all 63 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class MatchCounting with a public method long long count(int n) · 63 test cases · 2 s / 256 MB per case

Submitting as anonymous