找到 n 个 比 s 大的,在两种或两种以上的进制( 2 - 10 进制 )下是回文串的数,并输出出来
#include <cstdio>
using namespace std;
int main()
{
freopen("dualpal.in", "r", stdin);
freopen("dualpal.out", "w", stdout);
int n, s, t = 0, num;
scanf("%d%d", &n, &s);
while(t < n){
s ++;
int cnt = 0, a[100], tot = 0;
for(int k = 2; k <= 10; k ++){
num = s; tot = 0;
while(num){
a[++ tot] = num % k;
num /= k;
}// printf("%d ", k);
// for(int i = tot; i >= 1; i --) printf("%d ", a[i]); printf("\n");
bool ok = 1;
for(int i = tot; i >= 1; i --) if(a[i] != a[tot - i + 1]) { ok = 0; break; }
if(ok) cnt++;
if(cnt >= 2) { printf("%d\n", s); t ++; break; }
}
}
return 0;
}