Hdu 2054 A = = B? (Java)

Source: Internet
Author: User

Problem:
Consider the problem is not thoughtful, do not take into account may be a decimal and there is 1.0=1;01=1 situation.
The topic uses the BigDecimal class, which applies to high-precision numbers when solving the problem of decimals and 01=1,

In this class of comparison, N.equal (m) is relatively accurate, while N.compareto (m) ==0 only compares values for the problem.


A = = B?Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 73236 Accepted Submission (s): 11545


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 print "NO".
Sample Input
1 22 23) 34 3

Sample Output
Noyesyesno


Code:

Import Java.math.bigdecimal;import java.util.*;p ublic class main{public static void Main (string[] args) {Scanner cin=new Scanner (system.in); while (Cin.hasnextbigdecimal ()) {BigDecimal n=cin.nextbigdecimal (); BigDecimal M=cin.nextbigdecimal (); if (N.compareto (m) ==0) System.out.println ("YES"); ElseSystem.out.println ("NO");}}


Hdu 2054 A = = B? (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.