12分,求助
查看原帖
12分,求助
1200401
wnqnld_llx楼主2024/3/21 15:57

求助样例没错,但只有#1AC

#include<bits/stdc++.h>
using namespace std;
string num="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string v(int n,int x){
	string pop="";
	while(n!=0){
		pop+=num[n%x];
		n/=x;
	}
	string pop2="";
	for(int i=pop.length()-1;i>=0;i--){
		pop2+=pop[i];
	}
	return pop2;
}
bool hui(string pop){
	string pop2="";
	for(int i=pop.length()-1;i>=0;i--){
		pop2+=pop[i];
	}
	for(int i=pop.length()-1;i>=0;i--){
		if(pop2[i]-'0'!=pop[i]-'0') return 0;
	}
	return 1;
} 
int main(){
	int b;
	cin>>b;
	for(int i=1;i<=300;i++){
		string check=v(i*i,b);
		if(hui(check)){
			cout<<i<<" "<<check<<endl;
		}
	}
	return 0;
}`
2024/3/21 15:57
加载中...