2054 大数模拟 水题(略坑)
来源:互联网 发布:浅谈移动通信网络优化 编辑:程序博客网 时间:2024/05/22 17:15
A == B ?Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 89356 Accepted Submission(s): 14145Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".Inputeach test case contains two numbers A and B.Outputfor each case, if A is equal to B, you should print "YES", or print "NO".Sample Input1 22 23 34 3Sample OutputNOYESYESNOAuthor8600 && xhdSource校庆杯Warm UpRecommendlinle
#include<stdio.h>#include<string.h>char A[100000];char B[100000];void change(char s[]){ int point=0,len=strlen(s); for(int i=len-1;i>=0;i--) if(s[i]=='.') {point=1;break;} if(point) { int K; for(K=len-1;s[K]=='0';K--) s[K]='\0'; if(s[K]=='.') s[K]='\0'; }}int main(void){ while(scanf("%s %s",A,B)!=EOF) { int lenA=strlen(A),lenB=strlen(B); //先排除前置0 int top_i=0,top_j=0; while(A[top_i]=='0'&&top_i<lenA-1&&A[top_i+1]!='.') top_i++;//不减到最后一位以防是0 while(B[top_j]=='0'&&top_j<lenB-1&&B[top_j+1]!='.') top_j++; //再排除后置0 change(A); change(B); int flag=strcmp(A+top_i,B+top_j); if(!flag) printf("YES\n"); else printf("NO\n"); } return 0;}/*这题WA了相当多此来找一个错误,结果是因为复制相同代码段时变量名没改全,还有逆向读取数组元素时用了i++这种低级错误*/
0 0
- 2054 大数模拟 水题(略坑)
- 大数除法(模拟除)
- poj 2632 Crashing Robots【模拟】【略坑~】【刷题计划】
- 1002 大数相加 (简单模拟) 水题
- poj 1001 -- Exponentiation (大数计算,模拟)
- 求1000!(通过数组模拟大数)
- 大数阶乘(模拟手算过程)
- HDU 1013_Digital Roots(大数&模拟)
- hdu 5585 Numbers(字符串模拟大数)
- HDU 1047(大数相加)(数组模拟)
- 大数乘法(模拟相乘,分块)
- hdu 5568(dp+大数模拟)
- HDU1502 Regular Words(DP+大数模拟)
- Problem 13 Large sum (大数模拟)
- Chinese Girls' Amusement (大数模拟)
- 字符串模拟大数四则运算(转)
- 大数相加,模拟计算器
- [ACM]模拟大数加法
- InputStreamReader
- 2055 签到题
- ParNew 和 Parallel Old
- 丑数
- 网桥与交换机的区别
- 2054 大数模拟 水题(略坑)
- js 在线调试页面
- BZOJ1455: 罗马游戏
- 1002 大数相加 (简单模拟) 水题
- Android中adb工具的一些简单使用
- 图片替换
- sizeof详解 字节对齐
- libuv学习笔记(16)
- HDU2199 二分查找(浮点型) 水题