▲1.6 [hduoj] 2054 A == B ?

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

#include<stdio.h>
#include<string.h>
void change(char c[100000]);
char k[100000],t[100000];
void main()
{
    while(scanf("%s%s",&k,&t)!=EOF)
    {
        change(k);
        change(t);
        if(!(strcmp(k,t)))
            printf("YES\n");
        else
            printf("NO\n");
    }
}
void change(char c[])
{
    int len=strlen(c);
    if(strstr(c,"."))
    {
        for(int i=len-1;c[i]=='0';i--)
        {
            c[i]='\0';
            len--;
        }
    }
    if(c[len-1]=='.')
        c[len-1]='\0';
}

当我看到这题这么简单的时候我就知道。。肯定有问题。果然我第一次交上去的时候就跟我讲wrong answer。

我估摸着吧。是数据类型出了问题。第一遍的时候用的是double 错了 第二遍的时候用了long long 结果是输出时间超时。

好了。后来我就果断的去网上抄作业了。

网上说是高精度的问题。就是可能一个数它又臭又长,还tm是小数。所以可以用数组装这个数,把这个数多余的0和小数点去掉以后再比较。

最后!事实证明,这题的奸诈狡猾的出题人,数字会搞的很大,所以数组也要开的很大。

发布了153 篇原创文章 · 获赞 4 · 访问量 3718

猜你喜欢

转载自blog.csdn.net/qq_39782006/article/details/103850067