2054 A==B?

来源:互联网 发布:淘宝专享服务 编辑:程序博客网 时间:2024/06/02 01:01


A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 59989    Accepted Submission(s): 9272


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 22 23 34 3
 

Sample Output
NOYESYESNO

#include<iostream>#include<cstdio>#include<cstring>using namespace std;char a[15000],b[15000];int main(){    int a1,a2,b1,b2,i,j,tof;    while(~scanf("%s%s",a,b))    {        a1=b1=0;        tof=1;        a2=strlen(a)-1;        b2=strlen(b)-1;             while(a[a1]=='0') a1++;        if(strchr(a,'.')) while(a[a2]=='0') a2--;        if(a[a2]=='.') a2--;        while(b[b1]=='0') b1++;        if(strchr(b,'.')) while(b[b2]=='0') b2--;        if(b[b2]=='.') b2--;        if(a2-a1==b2-b1)        {            for(i=0;i<=a2-a1;i++)                if(a[a1+i]!=b[b1+i])                {                    tof=0;                    break;                }        }        else        {            printf("NO\n");            continue;        }        if(tof) printf("YES\n");        else printf("NO\n");    }}


0 0
原创粉丝点击