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
思路:真正的大牛说这是个水体,不仅有java10行秒过的,还有c小几十行的,醉醉哒,我是渣渣就正常模拟
我们这么做,每次处理一个串,将首先判断符号,当一正一负只有-0==0情况是这样的,其他都是NO。然后同号的时候我们去掉前导0,去掉后导0,如果是xxx.0那么去掉后两位,喵的凸(艹皿艹 )最最坑爹的数据来了 10.==10 讲真我搞不懂这尼玛是什么数据!但是就是这么坑。。。然后简单模拟就行了
上我的丑代码
#include<bits/stdc++.h>
#define input freopen("input.txt","r",stdin)
using namespace std;
string s1,s2;
string handle(string a){
string key=a,shut="";
int first0,end0,point,i,j;
for(first0=0;first0<key.size();first0++){ //去前导0
if(key[first0]!='0'||first0+1==key.size()||key[first0+1]=='.'){
break;
}
}
for(i=first0;i<key.size();i++){
shut+=key[i];
}
for(point=-1,i=0;i<key.size();i++){
if(key[i]=='.'){
point=i;
break;
}
}
if(point==-1) return shut; //如果没有小数点不需要去尾
shut=""; //需要去尾,那么从新赋值
for(end0=key.size()-1;end0>=point;end0--){ //去后导0
if(key[end0]!='0'||key[end0-1]=='.'){
break;
}
}
if(key[end0]=='0'&&key[end0-1]=='.'){ //去掉xx.0后两位
end0-=2;
}
if(key[end0]=='.'){ //去掉只有.的情况,坑点
end0-=1;
}
for(i=first0;i<=end0;i++){
shut+=key[i];
}
return shut;
}
int main(){
string a,b;
while(cin>>a>>b){
if((a[0]=='-'&&b[0]!='-')||(a[0]!='-'&&b[0]=='-')){
if(a[0]=='-'){
a=a.substr(1);
if(handle(a)==handle(b)&&handle(a)=="0"){
cout<<"YES"<<endl;
continue;
}
}
if(b[0]=='-'){
b=b.substr(1);
if(handle(a)==handle(b)&&handle(a)=="0"){
cout<<"YES"<<endl;
continue;
}
}
cout<<"NO"<<endl;
continue;
}
if(a[0]=='-'&&b[0]=='-'){
a=a.substr(1);
b=b.substr(1);
}
s1=handle(a);
s2=handle(b);
if(s1==s2)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}