Even-Hating Number
Time limit1sMemory limit1024 MB
Count and find the K-th largest number under 10^N whose digit string uses only 3, 5, 7 and each of these digit counts is odd.
- Level
Medium7 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Implementation
- Solved
- No attempts yet
Problem
Dodo's friend hates even numbers. So much that just seeing an even number makes him breathe fire and explode with rage.
For his friend, Dodo invented the even-hating number.
An even-hating number consists of , , and , and the count of s, the count of s, and the count of s are simultaneously not even. If a digit is used times, it is considered even.
For example, is an even-hating number because the count of s is , the count of s is , and the count of s is , so all digit counts are simultaneously not even.
Write a program that prints the -th largest even-hating number among numbers less than .
No input is given for which the answer does not exist.
Input
The first line gives the integer () and the integer ().
Output
On the first line, print the -th largest even-hating number among numbers less than .
Hint
can be represented with an 8-byte data type.
However, the sample 2 output cannot be represented with an 8-byte data type.