给出 n 进行多组询问,每次询问给出一个 ki ,求小于等于 n 的回文数中,最小的一个是 Ki 的倍数的数,如果不存在则输出 none。
我的代码:
#include<bits/stdc++.h>
#define int long long
using namespace std;
bool check(int n)
{
int x = 0;
int s = n;
while(s>0){
x = x*10+s%10;
s = s/10;
}
if(x==n){
return 1;
}
else{
return 0;
}
}
signed main(){
int n,q;
cin>>n>>q;
for(int i=1;i<=q;i++)
{
bool ok=0;
int k;
cin>>k;
if(k<10){cout<<k<<endl;continue;}
for(int i=2;i*k<=n;i++)
{
if(check(i*k)){cout<<i*k<<endl;ok=1;break;}
}
if(!ok){cout<<"none"<<endl;}
}
return 0;
}
请大佬看看哪里不对