标签:hdoj a b
1 2 2 2 3 3 4 3
NO YES YES NO#include<cstdio> #include<cstdlib> #include<cstring> using namespace std; char str[1000000],s[1000000]; int main() { int l,n,i,j,dot,a,b,c,d,sign,flag; while(scanf("%s %s",str,s)!=EOF){ l=strlen(s);n=strlen(str); sign=flag=0; if(str[0]=='-')sign=1; if(s[0]=='-')flag=1; for(i=0;i<n;++i){ if(str[i]=='-'&&i==0)continue; if(str[i]!='0')break; } for(j=0;j<l;++j){ if(s[j]=='-'&&j==0)continue; if(s[j]!='0')break; } a=i;b=j;c=n-1;d=l-1; if(strchr(str,'.')){ for(i=n-1;i>=0;--i){ if(str[i]!='0'){ c=i;break; } } }if(str[c]=='.')c--; if(strchr(s,'.')){ for(j=l-1;j>=0;--j) if(s[j]!='0'){ d=j;break; } }if(s[d]=='.')d--; if(a>b){ for(i=b;i<=d;++i){ if(str[i+a-b]!=s[i])break; } if((i-1)==d&&(i+a-b-1)==c&&sign==flag)printf("YES\n"); else printf("NO\n"); } else { for(j=a;j<=c;++j){ if(str[j]!=s[j+b-a])break; } if((j-1)==c&&(j+b-a-1)==d&&sign==flag)printf("YES\n"); else printf("NO\n"); } } return 0; }
标签:hdoj a b
原文地址:http://blog.csdn.net/r1986799047/article/details/42807129