TheNumbersWithLuckyLastDigit
SRM 504.5 · 2011-04-28 · by Vasyl[alphacom]
Problem Statement
John believes that the digits 4 and 7 are lucky, and all other digits are unlucky.
A positive integer is called a lucky number if its last digit is lucky.
For example, 4, 14 and 207 are lucky numbers, while 40, 741 and 3 are not lucky numbers.
John would like to represent the
Constraints
- n will be between 1 and 1,000,000,000, inclusive.
99 Returns: 4
One of the possible representations is 99=14+24+27+34.
11 Returns: 2
11=4+7.
13 Returns: -1
It is impossible to achieve the goal.
1234567 Returns: 1
1 Returns: -1
Submissions are judged against all 89 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheNumbersWithLuckyLastDigit with a public method int find(int n) · 89 test cases · 2 s / 256 MB per case