有问题
查看原帖
有问题
1328532
Tmc2012楼主2024/6/8 12:53
#include <bits/stdc++.h>
using namespace std;
string zjz(int x,int y)
{
	string ans="";
	while(x!=0)
	{
		if(x%y<=9) ans+=x%y+48;
		else ans+=x%y-10+'A';
		x/=y;
	}
	return ans;
}
bool check(string s)
{
	string x=s;
	reverse(x.begin(),x.end());
	if(x==s) return true;
	else return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int b;
	cin>>b;
	for(int i=1;i<=300;i++)
	{
		string s=zjz(i*i,b);
		if(check(s)) cout<<i<<" "<<s<<'\n';
	}
	return 0;
}

12分哪里错了

2024/6/8 12:53
加载中...