本来水题一个,结果因为一点顺序写反了,wa了一次,我晕!
code
/*
ID: yueqiq
PROG: dualpal
LANG: C++
*/
#include <set>
#include <map>
#include <ctime>
#include <queue>
#include <cmath>
#include <stack>
#include <limits>
#include <vector>
#include <bitset>
#include <string>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <string.h>
#include <iostream>
#include <algorithm>
#define Si set<int>
#define LL long long
#define pb push_back
#define PS printf(" ")
#define Vi vector<int>
#define LN printf("\n")
#define lson l,m,rt << 1
#define rson m+1,r,rt<<1|1
#define SD(a) scanf("%d",&a)
#define PD(a) printf("%d",a)
#define SET(a,b) memset(a,b,sizeof(a))
#define FF(i,a) for(int i(0);i<(a);i++)
#define FD(i,a) for(int i(a);i>=(1);i--)
#define FOR(i,a,b) for(int i(a);i<=(b);i++)
#define FOD(i,a,b) for(int i(a);i>=(b);i--)
#define readf freopen("input.txt","r",stdin)
#define writef freopen("output.txt","w",stdout)
const int maxn = 101;
const int INF = 0x3fffffff;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
const double pi = acos(-1.0);
using namespace std;
string a[10]={"0","1","2","3","4","5","6","7","8","9"};
string change(int n,int t){
string ans="";
while(n){
int tmp=n%t;
n/=t;
ans.insert(0,a[tmp]);
}
return ans;
}
bool judge(string t){
int len=t.length();
FOR(i,0,len/2-1){
if(t[i]!=t[len-1-i])
return false;
}
return true;
}
int main(){
ifstream cin( "dualpal.in" ) ;
ofstream cout( "dualpal.out" ) ;
int N,S;
cin>>N>>S;
int cnt=0;
while(1){
S++;
int t=0;
FOR(i,2,10){
string tmp=change(S,i);
if(judge(tmp)) t++;
if(t>=2){ //这一块应写在t++的下面,以后注意
cout<<S<<endl;
N--;
break;
}
}
if(N==0) break;
}
return 0;
}