有没有大佬帮忙看看为什么WA
查看原帖
有没有大佬帮忙看看为什么WA
705406
AK360楼主2024/8/11 20:37
#include<bits/stdc++.h>
using namespace std;
bool h(int n)
{
	if(n<=9)
	{
		return 1;
	}
	int y=0;
	int x=n;
	while(x>0)
	{
		y=y*10+x%10;
		x=x/10;
	} 
	if(y==n)
	{
		return 1;
	}
	return 0; 
}
long long q(int n)
{
	if(n<=9)
	{
		return n;
	}
	int x=n,y=0;
	while(x>0)
	{
		y=y*10+x%10; 
		x/=10;
	}
	return y; 
} 
int main ()
{
	int m,n=0;
	string s;
	cin>>m;
	if(m==10)
	{
		cin>>n; 
	} 
	else if(m==2)
	{
		cin>>s;
		for(int i=0;i<s.size();i++)
		{
			n=n+s[i]*pow(2,i);
		}
	} 
//	if(h(n))
//	{
//		cout<<n;
//	}
	int d=0; 
	while(d<=30)
	{
		d++;
		n+=q(n);
		if(h(n))
		{
			cout<<"STEP="<<d;
			return 0;
		}
	}
	cout<<"Impossible!";
	return 0;
}
2024/8/11 20:37
加载中...