Hdu 2054 A = B?
A = B?Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 64227 Accepted Submission (s): 10057
Problem DescriptionGive you two numbers A and B, if A is equal to B, you shoshould print "YES", or print "NO ".
Inputeach test case contains two numbers A and B.
Outputfor each case, if A is equal to B, you shoshould print "YES", or print "NO ".
Sample Input
1 22 23 34 3
Sample Output
NOYESYESNO: Check whether a is equal to B. Thinking: There are many situations where there are symbols, unsigned ones, or 0.1 and. 1 is equal, but also pay attention to the useless 0. I will remove all the useless 0 behind the front and back, and then judge the problem of the symbol by minute. the decimal point problem, the code is long, there is a very short code, and it has passed, but 01 and 1, + 1 and 1 are not correct in many cases, but it is correct !,,, I don't quite understand. Attach the super short code. This question is really annoying!# Include
# Include
Char a [150000], B [150000], c [150000], d [150000]; int main () {int I, j, k, l, lena, lenb; while (scanf ("% s", a, B )! = EOF) {lena = strlen (a); lenb = strlen (B); for (I = 0; I
= 0; j --) {if (a [j]! = '0') {a [j + 1] = '\ 0'; break ;}} if (a [j] = '. ') a [j] =' \ 0'; break ;}// remove the useless 0 behind the decimal point for (I = 0; I
= 0; j --) {if (B [j]! = '0') {B [j + 1] = '\ 0'; break ;}} if (B [j] = '. ') B [j] =' \ 0'; break;} // remove the useless 0 behind the decimal point if (strcmp (a, B) = 0) printf ("YES \ n"); else if (a [0] = '+' & B [0] = '-') | (a [0] = '-' & B [0] = '+') // printf ("NO \ n") with different symbols "); else if (a [0] = '+' & B [0] = '+ ') | (a [0] = '-' & B [0] = '-') {// for (I = 1; I
# Include
Char a [150000], B [150000]; void f (char * s) {int lens; lens = strlen (s); if (strchr (s ,'.')! = NULL) {while (s [-- lens] = '0'); if (s [lens] = '. ') lens --; s [lens + 1] =' \ 0';} int main () {while (scanf ("% s", a, B) = 2) {f (a); f (B); if (strcmp (a, B) = 0) printf ("YES \ n "); else printf ("NO \ n");} return 0 ;}