Super Lucky Palindromes
시간 제한1초메모리 제한1024 MB
각 k에 대해, 길이와 4 또는 7의 개수도 럭키 넘버인 4와 7로만 이루어진 회문 중 k번째로 작은 수를 구한다.
문제
Lucky numbers are positive integers composed only of the digits ‘4’ and ‘7’. For example, 47477 and 777 are lucky numbers while 457 and 1232 are not.
Super lucky numbers have the following additional properties:
- They are a lucky number themselves
- Number of digits in them is a lucky number
- The number of ‘4’s or the number of ‘7’s in them is a lucky number (or both counts are lucky numbers).
A palindrome is an integer that reads the same forwards and backwards. For example, 547745 and 343 are palindromes while 74 and 12345 are not. A super lucky palindrome is a positive integer that is both a super lucky number and a palindrome.
Given a number k, print the k th smallest super lucky palindrome.
입력
The first input line contains a positive integer, n, indicating the quantity of numbers to check. Each of the next n lines contains a single integer, k (1 ≤ k ≤ 1018).
출력
For each query, first output the heading “Query #d: ”, where d is the query number, starting with 1. Then, for the value k given in the query, print the k th smallest super lucky palindrome. Follow the format illustrated in Sample Output.