A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 51920 Accepted Submission(s): 8014
Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
Input
each test case contains two numbers A and B.
Output
for each case, if A is equal to B, you should print "YES", or print "NO".
Sample Input
1 2 2 2 3 3 4 3
Sample Output
NO YES YES NO
<pre name="code" class="java">import java.math.BigDecimal; import java.math.BigInteger; import java.math.MathContext; import java.util.Scanner; public class Main{ public static void main(String args[]){ Scanner cin = new Scanner(System.in); while(cin.hasNext()){ BigDecimal a = cin.nextBigDecimal(); BigDecimal b = cin.nextBigDecimal(); if(a.equals(BigDecimal.valueOf(0.0))) a = BigDecimal.ZERO; if(b.equals(BigDecimal.valueOf(0.0))) b = BigDecimal.ZERO; if(a.stripTrailingZeros().toPlainString().equals(b.stripTrailingZeros().toPlainString())) System.out.println("YES"); else { System.out.println("NO"); } } cin.close(); } }
#include<stdio.h> #include<string.h> char *removepoint(char a[])//不用考虑前导0...这让我很困惑啊..Dev结果都不对还能AC { int len = strlen(a); //strchr的功能 : //返回首次出现c的位置的指针,返回的地址是字符串在内存中 //随机分配的地址再加上你所搜索的字符在字符串位置,如果s中不存在c则返回NULL if(strchr(a,'.')!=NULL) { while(a[--len] == '0'); if(a[len]=='.') len--; a[len+1] = '\0'; } return a; } int main() { char a[15000],b[15000]; while(~scanf("%s%s",a,b)) { if(strcmp(removepoint(a),removepoint(b))==0) printf("YES\n"); else printf("NO\n"); } return 0; }