提交时间:2025-05-25 12:40:32
运行 ID: 324252
#include<bits/stdc++.h> using namespace std; string s; string s1; string s2; long long m; void sgh(long long x,int y){ char c; s=""; while(x>0){ if(x%y<10){ c=x%y+'0'; }else{ c=x%y+'A'-10; } s=c+s; x/=y; } } bool sb(long long d){ int a=0; int w,t; t=d; while(t>0){ w=t%10; a=a*10+w; t/=10; } if(d==a) return 1; return 0; } int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>m; if(sb(m)) continue; for(int j=2;j<=16;j+=14){ sgh(m,j); s2=s; reverse(s.begin(),s.end()); if(s2==s){ cout<<m<<endl; } } } return 0; }