Uva
来源:互联网 发布:淘宝产品质检报告 编辑:程序博客网 时间:2024/06/03 04:58
Wrong Anwser:
#include<stdio.h>#include<string.h>#define MAX_LEN 233int main (){ int i,j,lm,lp,min1,min2,slocation; char tbottom[MAX_LEN],ttop[MAX_LEN],temp[MAX_LEN]; while( scanf("%s",tbottom) != EOF ) { scanf("%s",ttop); lp=strlen(ttop); lm=strlen(tbottom); for(i=0,j=0,slocation=0; i<lp;) { if((ttop[i]+tbottom[j]-'0'-'0')>3) { i=0; slocation++; j=slocation; tbottom[lm+slocation-1]='0'; tbottom[lm+slocation]='\0'; continue; } else { i++; j++; } } min1=((slocation+lp)<lm?lm:(slocation+lp)); strcpy(temp,ttop); strcpy(ttop,tbottom); strcpy(tbottom,temp); for(i=0;i<lm-lp;i++) { ttop[lp+i]='0'; } ttop[lm]='\0'; for(i=0,j=0,slocation=0; i<lp;) { if((ttop[i]+tbottom[j]-'0'-'0')>3) { i=0; slocation++; j=slocation; ttop[lm+slocation-1]='0'; ttop[lm+slocation]='\0'; continue; } else { i++; j++; } } min2=(slocation+lm); printf("%d\n",(min1>min2?min2:min1)); } return 0;}
Acceped:
#include<stdio.h>#include<string.h>#define MAX_LEN 233int main () { int i,j,lm,lp,min1,min2,slocation; char tbottom[MAX_LEN],ttop[MAX_LEN],temp[MAX_LEN]; while( scanf("%s%s",tbottom,ttop) != EOF ) { lp=strlen(ttop); lm=strlen(tbottom); if(lp>lm) { strcpy(temp,ttop); strcpy(ttop,tbottom); strcpy(tbottom,temp); i=lp; lp=lm; lm=i; } for(i=0,j=0,slocation=0; i<lp;) { if((ttop[i]+tbottom[j]-'0'-'0')>3) { i=0; slocation++; j=slocation; tbottom[lm+slocation-1]='0'; continue; } else { i++; j++; } } min1=((slocation+lp)<lm?lm:(slocation+lp)); for(i=0; i<(lm-lp); i++) { ttop[lp+i]='0'; } for(i=0,j=0,slocation=0; i<lp;) { if((ttop[j]+tbottom[i]-'0'-'0')>3) { i=0; slocation++; j=slocation; ttop[lm+slocation-1]='0'; ttop[lm+slocation]='\0'; continue; } else { i++; j++; } } min2=(slocation+lm); printf("%d\n",(min1>min2?min2:min1)); } return 0;}
0 0
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- Windows Data Type
- win7 下解决python 集成编译环境IDLE无法打开的问题。
- Ajax技术之解决中文乱码问题
- floyd求最小环
- 代码混淆 GSON完满解决
- Uva
- Java System.out.println()的解释
- 条件随机场学习
- Shiro 分布式架构下 Session 的共享实现
- SpringMVC动态配置双数据源
- java设计模式之原型模式
- 在vs2015连接oracle的方法
- Sublime text 3基本问题随机笔记
- Android sqlite数据库操作笔记