本地对, 但2, 3,4 WA
查看原帖
本地对, 但2, 3,4 WA
527243
Iamzzr楼主2021/10/18 13:44
#include <bits/stdc++.h>
using namespace std;
int n;
string st;
int s[105], s1[105];
int check(int l){
	for(int i=0; i<l/2; i++)
		if(s[i]!=s[l-i-1]) return 0;
	return 1;
}

int main(){
	cin>>n;
	scanf("%s", s);
	int l=st.size();
	for(int i=0; i<l; i++){
		if(st[i]>='A' && st[i]<='Z') s[i]=st[i]-'A'+10;
		else s[i]=st[i]-'0';
//		cout<<s[i]<<" ";
	}
	for(int i=0; i<=30; i++){
		if(check(l)){
			cout<<"STEP="<<i;
			return 0;
		}
		for(int j=0; j<l; j++){
			s1[j]=s[l-j-1];
		}
		int x;
		for(int j=0; j<=l; j++){
			s[j]=s[j]+s1[j]+x;
			x=s[j]/n;
			s[j]-=x*n;
		}
		if(s[l]>0) l++;
	}
	cout<<"Impossible!";
	return 0;
}  
2021/10/18 13:44
加载中...