TheSumOfLuckyNumbers
SRM 403 · 2008-05-29 · by Vasyl[alphacom]
Problem Statement
John thinks 4 and 7 are lucky digits, and all other digits are not lucky. A lucky number is a number that contains only lucky digits in decimal notation.
Some numbers can be represented as a sum of only lucky numbers. Given an
Constraints
- n will be between 1 and 1,000,000, inclusive.
11
Returns: {4, 7 }
It is simple: 11 = 4 + 7.
12
Returns: {4, 4, 4 }
Now we need three summands to get 12.
13
Returns: { }
And now we can not get 13 at all.
100
Returns: {4, 4, 4, 44, 44 }
1000000
Returns: {4, 4, 44444, 477774, 477774 }
Submissions are judged against all 75 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TheSumOfLuckyNumbers with a public method vector<int> sum(int n) · 75 test cases · 2 s / 256 MB per case