2054 大数模拟 水题(略坑)
2016-06-23 21:17
405 查看
A == B ? Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 89356 Accepted Submission(s): 14145 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 Author 8600 && xhd Source 校庆杯Warm Up Recommend linle
#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++这种低级错误*/
相关文章推荐
- ParNew 和 Parallel Old
- 2055 签到题
- 第十五周(3)-阅读程序
- Thymeleaf基础知识
- CodeForces 569A Music
- 1062 字符串处理 水题
- 01背包
- 2021 贪心算法 (最优转载问题)水题
- 学习笔记2__布局:固定顶栏布局
- hdu 2136 素数打表
- matlab对excel数据进行排序求和
- windows7 64位 编译 openssl
- 最长公共子序列(未完成)
- 毕向东Java视频学习笔记【Day09 继承+接口+抽象类】
- 转: 通过不到100行Go代码打造你自己的容器
- Android 手势滑动
- hdu 1286 素数打表
- Android 解析后台返回为Json数据的简单例子
- MyBatis分页插件:比PageHelper都要简单,使用很灵活,目前支持Oracle和MySQL
- 结构体和预定义