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
用C++写太麻烦了,需要考虑各种情况,前导零,后导零,正负数,整数小数。。。
直接用java水过。。。
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        BigDecimal x, y;
        while(cin.hasNextBigDecimal()){
            x = cin.nextBigDecimal().stripTrailingZeros();
            y = cin.nextBigDecimal().stripTrailingZeros();
            if(x.equals(y))
                System.out.println("YES");
            else
                System.out.println("NO");
        }
    }

}


posted @ 2014-12-21 14:26  Popco  阅读(232)  评论(0编辑  收藏  举报