A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 67197 Accepted Submission(s): 10467
Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
Input
each test case contains two numbers A and B.
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
Sample Input
1 2 2 2 3 3 4 3
Sample Output
NO YES YES NO
Author
8600 && xhd
Source
#include<iostream>
#include<cstring>
using namespace std;
void qq(char *a)
{
int len,i;
len=strlen(a)-1;
for(i=len;i>=0;i--)
{
if(a[i]=='0')
len--; //去掉小数点后的0
else
break;
}
if(a[len]=='.') //如果小数点后全是0,那小数点也得去掉
len--;
a[len+1]='\0'; //通过加结束标志来去掉
}
int main()
{
int i,len;
char a[50000],b[50000];
while(cin>>a>>b)
{
len=strlen(a);
for(i=0;i<len;i++)
{
if(a[i]=='.') //对有小数点的数据处理
qq(a);
}
len=strlen(b);
for(i=0;i<len;i++)
{
if(b[i]=='.')
qq(b);
}
if(strcmp(a,b))
cout<<"NO"<<endl;
else
cout<<"YES"<<endl;
}
return 0;
}
超时严重