复制代码
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 using LL = long long;
 4 #define eb(n) emplace_back(n)
 5 vector<LL> ans;
 6 inline LL trans(LL n) {
 7     LL x = 0;
 8     while (n) {
 9         x = x * 10 + n % 10;
10         n /= 10;
11     }
12     return x;
13 }
14 void gene() {
15     for (LL i = 0; i <= 9; i++) {
16         ans.emplace_back(i);
17         for (LL j = 1; j <= 9; j++) {
18             LL res = j * 100 + i * 10 + j;
19             ans.emplace_back(res);
20         }
21         for (LL j = 10; j <= 99; j++) {
22             LL res = j * 1000 + i * 100 + trans(j);
23             ans.emplace_back(res);
24         }
25         for (LL j = 100; j <= 999; j++) {
26             LL res = j * 10000 + i * 1000 + trans(j);
27             ans.emplace_back(res);
28         }
29         for (LL j = 1000; j <= 9999; j++) {
30             LL res = j * 100000 + i * 10000 + trans(j);
31             ans.emplace_back(res);
32         }
33         for (LL j = 10000; j <= 30000; j++) {
34             LL res = j * 1000000 + i * 100000 + trans(j);
35             ans.emplace_back(res);
36         }
37     }
38     for (LL i = 0; i <= 99; i+=11) {
39         ans.emplace_back(i);
40         for (LL j = 1; j <= 9; j++) {
41             LL res = j * 1000 + i * 10 + j;
42             ans.emplace_back(res);
43         }
44         for (LL j = 10; j <= 99; j++) {
45             LL res = j * 10000 + i * 100 + trans(j);
46             ans.emplace_back(res);
47         }
48         for (LL j = 100; j <= 999; j++) {
49             LL res = j * 100000 + i * 1000 + trans(j);
50             ans.emplace_back(res);
51         }
52         for (LL j = 1000; j <= 9999; j++) {
53             LL res = j * 1000000 + i * 10000 + trans(j);
54             ans.emplace_back(res);
55         }
56         
57     }
58     
59     sort(ans.begin(), ans.end());
60  
61     //printf("%d\n", ans.size());
62 }
63 int main()
64 {
65     gene();
66     int tt;
67     cin >> tt;
68     while (tt--) {
69         int n;
70         scanf("%d", &n);
71         printf("%lld\n", ans[n + 1]);
72     }
73     return 0;
74 }
复制代码