为什么进位错了,没有工作?
查看原帖
为什么进位错了,没有工作?
1050431
DevilsFlame楼主2023/12/15 13:05
#include<bits/stdc++.h>
#define LL long long
using namespace std;
long long a,b,n,ans=0,f[17]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16},x=30;
int hui(long long w,int q){
	long long h=w,z=0;
	while(h){
		z=z*10+(h%10);
		h/=10;
	}
	if(q==2){
		return z;
	}
	if(z==w)
		return 1;
	return 0;
}
int wei(LL x){
	if(!x)
		return 1;
	int q=0;
	while(x){
		q++;
		x/=10;
	}
	return q;
}
int pow(int a){
	LL s=1;
	while(a--){
		s*=10;
	}
	return s;
}
int main(){
	cin>>n;
	cin>>a;
	while(x--){
		if(hui(a,1)){
			cout<<"SETP="<<30-x-1<<endl;
			return 0;
		}
		b=hui(a,2);
		for(int i=1;i<=wei(a);i++){
			LL ww=pow(i-1);
			a+=(b/ww%10)*ww;
			if((a/ww%10)>f[n]){
				a+=ww*10;
				a-=f[n]*ww;
			}
		}
	}
	cout<<"Impossible!"<<endl;
	return 0;
}
2023/12/15 13:05
加载中...