欢迎来到PJCK的博客

(stripTrailingZeros)A == B hdu2054

A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 117898    Accepted Submission(s): 18821

 

 

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

 

 

可以用java大数

 

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        BigDecimal a;
        BigDecimal b;
        while(in.hasNextBigDecimal()) {
            a=in.nextBigDecimal();
            b=in.nextBigDecimal();
            a=a.stripTrailingZeros();           //去掉小数点后面多余的0.
            b=b.stripTrailingZeros();
            if(a.equals(b))
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }
}

 

posted @ 2018-06-11 12:09  PJCK  阅读(146)  评论(0编辑  收藏  举报