luogu_MeiFengqi @ 2022-08-24 13:01:46
测试的第一组数是 2 10011 答案是4,可我就想不明白10011明明就是19 19+91=110 110+011=121 两部都就行了,怎么有四步 求解<_<
by 大眼仔Happy @ 2022-08-24 13:02:54
@meifengqi 他是要二进制下的回文吧
by luogu_MeiFengqi @ 2022-08-24 13:08:52
@大眼仔Happy 对 在帮忙看一下代码:
#include<bits/stdc++.h>
using namespace std;
int m,qs,b[101],po=0;
long s;
char a[101];
bool sq=true;
int jz(long s)
{
int l=strlen(a);
int s1=0;
for(int i=0;i<l;i++)
{
if(a[i]>='0'&&a[i]<='9')
s1=a[i]-'0';
else if (m>=11&&(a[i]>='A'+m-10))
s1=a[i]-'A'+10;
s=s*m+s1;
}
return s;
}
void HWS(int qs,int temp)
{
while(temp!=0)
{
qs=qs*10+temp%10;
temp/=10;
}
if(qs==po) sq=false;
else sq=true;
return;
}
int main()
{
scanf("%d",&m);
scanf("%s",a);
int ans=0;
po=jz(s);
while(sq)
{
int ss=po;
ans++;
int q=10,w=1;
while(po/q!=0)
{
q*=10;
w++;
}
int e=1;
do{
b[e]=ss%10;
ss/=10;
e++;
}while(ss>0);
for(int i=w,k=1;i>=1;i--,k*=10)
b[i]*=k;
for(int i=1;i<=w;i++)
po+=b[i];
HWS(0,po);
if(ans>30)
{
printf("Impossible!");
return 0;
}
}
printf("STEP=%d",ans);
return 0;
}
by luogu_MeiFengqi @ 2022-08-29 11:58:35
@大眼仔Happy
//在吗
//求助