首页 > 编程 > Java > 正文

HDU 2054 JAVA

2019-11-06 07:21:11
字体:
来源:转载
供稿:网友

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"); } } } }}
上一篇:HDU 2055 JAVA

下一篇:HDU 2053 JAVA

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表