public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
long k = sc.nextLong();
StringBuilder sb = new StringBuilder();
while (k > 0) {
if((k & 1) == 1) {
sb.append('4');
System.out.println(sb);
k = (k - 1) /2;
} else {
sb.append('7');
k = (k - 2)/2;
}
}
System.out.println(sb.reverse());
}
}
}
4和7是两个幸运数字,我们定义,十进制表示中,每一位只有4和7两个数的正整数都是幸运数字。前几个幸运数字为:4,7,44,47,74,77,444,447...
现在输入一个数字K,输出第K个幸运数。