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)