HDOJ_ACM 2054 using Java

Source: Internet
Author: User

Problem descriptiongive You both numbers A and B, if A is equal to B, you should print "YES", or print "NO". Inputeach test case contains-numbers a and B. Outputfor each case, if A was equal to B, you should print "YES", or Prin T "NO". Sample INPUT1 2 2 2 3 3 4 3 Sample Output

NO

YES

YES

NO

This problem should take into account decimal, large number, 0050,50 and so on these cases in C or C + + will be more troublesome

But having Bigdeimal in Java just solves this problem (ACM can be submitted in Java)

The code is as follows:

Import Java.util.*;import Java.math.bigdecimal;public class main{public static void Main (String args[])       {   BigDecimal A, b;           Scanner in=new Scanner (system.in);           while (In.hasnextbigdecimal ())           {   a=in.nextbigdecimal ();   b=in.nextbigdecimal ();   if (A.compareto (b) ==0) System.out.println ("YES");   Else System.out.println ("NO");}}}                 

  

HDOJ_ACM 2054 using Java

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.