FingerCounting
SRM 390 · 2008-02-02 · by srbga
Problem Statement
Constraints
- weakFinger will be between 1 and 5, inclusive.
- maxCount will be between 0 and 100000, inclusive.
Statement by TopCoder, Inc. — view the original on the archive.
2 3 Returns: 15
The first 15 numbers are counted with fingers 1,2,3,4,5,4,3,2,1,2,3,4,5,4,3. He would then have to use finger 2 for the next number, but since he has already used it 3 times, he has to stop.
1 0 Returns: 0
He needs to use his thumb when counting the first number, 1, but it's too weak to be used even once.
5 0 Returns: 4
Even though his pinky cannot be used at all, he can count 1,2,3,4 with the other fingers.
2 48 Returns: 193
5 973 Returns: 7788
Submissions are judged against all 37 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class FingerCounting with a public method int maxNumber(int weakFinger, int maxCount) · 37 test cases · 2 s / 256 MB per case