This problem is solved directly by using Java and the bigdecimal type. However, there is still a situation in which an error will be judged, that is, the input is 0.0 and 0,ProgramIt is considered that they are not equal, probably because they are looking for the non-zero number in the front when removing the resulting zero. The solution is to add 1 to both numbers A and B to determine whether they are equal. But in this case,-1.0 and-1 will judge the error again. It's okay. Add another 1.
CodeAs follows:
Import Java. math. bigdecimal; import Java. math. biginteger; import Java. util. role; public class main {public static void main (string [] ARGs) {role in = new role (system. in); bigdecimal a, B; while (in. hasnextbigdecimal () {A = in. nextbigdecimal (); B = in. nextbigdecimal (); A =. add (bigdecimal. one); B = B. add (bigdecimal. one); B = B. striptrailingzeros (); A =. striptrailingzeros (); if (. equals (B) {system. out. println ("yes");} else {A =. add (bigdecimal. one); B = B. add (bigdecimal. one); B = B. striptrailingzeros (); A =. striptrailingzeros (); if (. equals (B) {system. out. println ("yes");} else {system. out. println ("no") ;}}}