您的位置:首页 > 编程语言 > Java开发

HDU 2054 JAVA

2017-03-05 10:28 357 查看
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

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

class Main {

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

}
}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: