hdu2054 A == B ?(高精度比较)
2014-03-03 18:59
239 查看
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 56411 Accepted Submission(s): 8680
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
#include<stdio.h> #include<string.h> char a[100004],b[100004]; int dot(char x[]) { int len=strlen(x),i; for(i=0; i<len; i++) { if(x[i]=='.') { int j=len-1; while(x[j]=='0') {//去掉末尾的零 len--; j--; } break; } } if(x[len-1]=='.') len--;//去掉整数的小数点 return len; } int main() { while(scanf("%s%s",a,b)!=EOF) { int la=dot(a),lb=dot(b); if(la!=lb) { printf("NO\n"); continue; } bool ok=1; for(int i=0; i<la; i++) if(a[i]!=b[i]) { ok=0; break; } if(ok) printf("YES\n"); else printf("NO\n"); } return 0; }
相关文章推荐
- Windows下定时比较(高精度)
- [中等] 比较完整的BigInteger高精度整数类(C++实现)
- HDU2054 有点坑的大数比较
- BFS:HDU2054-A==B?(字符串的比较)
- hdu2054 看了许多大佬的想法 就是找小数点 比较两个字符串的函数
- 递归与循环的开销比较,高精度时间函数
- 【高精度】比较大小
- 模板:高精度整数比较大小
- MFC的CreateTimerQueueTimer和timeSetEvent两个高精度定时器的比较
- 关于pascal中高精度字符串型数的比较
- hiho1234--Fractal(高精度比较问题)
- JAVA高精度3_比较大小
- hiho1234--Fractal(高精度比较问题)
- 关于比较烂的书!----我到认为是好书!
- .Net 2.0内存对象布局详析及与1.1变化比较
- 最近做项目比较忙!嘿嘿……自己和自己玩玩儿
- 五大免费博客软件完全比较
- jdbc与hibernate的优缺点比较
- C++和Java动态数组比较
- 整理的比较全的event对像在ie与firefox浏览器中的区别