50分
查看原帖
50分
951034
zcs2012楼主2023/12/17 08:43

求助#3、#1不过

#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
int main(){
	char m[70];
	int n;
	scanf("%d%s",&n,m);
	for(int i=0;i<=30;i++){
		char x[70];
		for(int p=strlen(m),k=p;p--;)
			x[p]=m[k-p-1];
		if(!strcmp(m,x))
			printf("STEP=%d\n",i),exit(0);
		char y[70]={};
		int p1=strlen(m);
		memset(y,48,p1+1);
		for(;p1--;){
			int a=isdigit(m[p1])?m[p1]-48:m[p1]-55,b=isdigit(x[p1])?x[p1]-48:x[p1]-55;
//			printf("%d %d ",a,b);
			if((y[p1+1]+=(a+b)%n)>57)y[p1+1]+=7;
//			printf("%d\n",y[p1+1]);
			if(a+b>=n)y[p1]++;
		}
		strcpy(m,y[0]==48?y+1:y);
//		puts(m);
//		putchar('\n');
	}
	puts("Impossible!");
	return 0;
}
2023/12/17 08:43
加载中...