PAT1060【大模拟啊】

怎么麻烦怎么来了???
提供几个案例:

5 0.00001 0.00001

0 0.0 0.0222

1 0.001 0.2000

2 005.06 0.230

1 00.020 0


贴份代码跑。。

#include 
using namespace std;
typedef long long LL;
int n,m;
string s1,s2;
string a,b;
int main()
{
	int as,bs;
	cin>>n>>s1>>s2;
	as = s1.length();
	bs = s2.length();
	if(n==0)
	{
	        puts("YES 0.*10^0");
		return 0;
	}
	m = n;
	
	a = "0.";
	b = "0.";
	int num1_1 = 0,num1_2=0;
	bool flag = false;
	int i = 0;
	while(s1[i]=='0')
	{
		i++;
		n++;
	}
	bool flat = false;
	for(;i < n && i < as;i++)
	{
		if(s1[i] >= '0'&& s1[i] <= '9')
		{
			if(flag)
			{
				if(!num1_1&&!flat&&s1[i]=='0')
				{
					n++;
					num1_2++;
				}
				else
				{
					flat = true;
					a.push_back(s1[i]);
				}
			}
			else
			{
				a.push_back(s1[i]);
				num1_1++;
			}
		}
		else 
		{
			flag = true;
			n++;
		}
	}
	if(!flat) num1_2 = 0;
	else num1_2 = -num1_2; 
	
	if(!flag)
	{
		while(i < as)
		{
			if(s1[i] >= '0' && s1[i] <= '9')
				num1_1++;
			else break;
			i++;
		}
	}
	//printf("%d %d\n",i,n);
	while(i= '0' && s2[i] <= '9')
		{
			if(flag)
			{
				if(!num2_1&&!flat&&s2[i]=='0')
				{
					num2_2++;
					n++;
				}
				else 
				{
					flat = true;
					b.push_back(s2[i]);
				}
			}
			else
			{
				b.push_back(s2[i]);
				num2_1++;
			}
		}
		else
		{
			flag = true;
			n++;	
		}
	}
	if(!flat) num2_2 = 0;
	else num2_2 = - num2_2;
	
	if(!flag)
	{
		while(i < bs)
		{
			if(s2[i] >= '0' && s2[i] <= '9')
				num2_1++;
			else break;
			i++;
		}
	}
	
	while(i < n)
	{
		b.push_back('0');
		i++;
	}
	
	if(a == b && ((num1_1 && num1_1 == num2_1)||(!num1_1 && num1_2 == num2_2)))
	{
		cout<<"YES "<


你可能感兴趣的:(模拟,PTA_Accept)