符合条件的数分布很密集,直接枚举判断。
1 /*
2 ID: 31440461
3 LANG: C++
4 TASK: dualpal
5 */
6 #include<iostream>
7 #include<fstream>
8 using namespace std;
9
10 bool legal(int num)
11 {
12 int times=0;
13 for (int base=2;base<=10;base++)
14 {
15 int p=0,que[32],x=num;
16 x=num;
17 while (x)
18 {
19 que[++p]=x % base;
20 x=x/base;
21 }
22 bool ok=1;
23 for (int j=1;ok && (j+j<=p);j++) ok=(ok && que[j]==que[p-j+1]);
24 if (ok) times++;
25 if (times>1) return true;
26 }
27 return false;
28 }
29
30
31 int main()
32 {
33 int s,n;
34 ifstream fin("dualpal.in");
35 ofstream fout("dualpal.out");
36 fin>>n>>s;
37 for (int i=s+1;n;i++)
38 if (legal(i))
39 {
40 fout<<i<<endl;
41 n--;
42 }
43 return 0;
44 }
45