Sequence
Limits: 2 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Marichka really loves lucky digital sequences, and Zenyk is ready to get any such sequence for her. So, Marichka’s requirements for a lucky sequence are as follows:
The sequence consists of the digits 4 and 7.
The length of the sequence is \(n\).
Two fours do not appear consecutively in the sequence.
The sequence is at the \(k\)-th position in the lexicographically sorted list of all possible sequences.
You need to help Zenyk determine this sequence.
Input
The single line contains two positive integers \(n\) and \(k\) — the length of the sequence and the position in the sorted list of all possible sequences, respectively.
Output
In the single line, print the \(k\)-th lucky sequence, or
Flowers if \(k\) is
greater than their total number.
Constraints
\(1 \le n \le 80\),
\(1 \le k \le 10^{18}\).
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 7 | 7774 |
| Input (stdin) | Output (stdout) |
|---|---|
| 3 10 | Flowers |
Notes
Sorted list of sequences of length 4 and 3 respectively:
4747, 4774, 4777, 7474, 7477, 7747, 7774, 7777.
474, 477, 747, 774, 777.
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|