AllEven
SRM 771 · 2019-11-26 · by misof
SRM 771 · 2019-11-26 · by misof · Dynamic Programming
Problem Statement
Problem Statement
A number is paired up if the number of occurrences of each digit is even. For example, 22, 4242, and 7720707727 are paired up, but 33033 and 12345 are not.
Given the
Constraints
- hi will be between 0 and 10^18 - 1, inclusive.
- lo will be between 0 and hi, inclusive.
Examples
0)
47 999 Returns: 5
The five numbers are 55, 66, 77, 88, and 99.
1)
47 1010 Returns: 7
Compared to the previous example we now also gained 1001 and 1010.
2)
12345678901 98765432109 Returns: 0
3)
1234 654321 Returns: 6862
4)
0 10 Returns: 0
Note that zero is not a paired up number, as it has an odd number of zeros.
Submissions are judged against all 78 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class AllEven with a public method long long countInRange(long long lo, long long hi) · 78 test cases · 2 s / 256 MB per case