UVa 1588 Kickdown
2015-10-11 23:55
113 查看
数组开大点
#include <iostream> #include <cstring> #include <algorithm> using namespace std; char bottom[1010]; char top[1010]; int main() { while(cin >> bottom >> top) { //from left int bl = strlen(bottom); int tl = strlen(top); int len = max(bl, tl); int i, j; int res1 = 0; int res2 = 0; int res; for(i = 0; i < bl; i++) { for(j = 0; j < tl; j++) { if(bottom[i+j] + top[j] - '0' - '0' > 3) { break; } } if(j == tl) { break; } } res1 = i + tl; for(i = 0; i < tl; i++) { for(j = 0; j < bl; j++) { if(bottom[j] + top[i+j] - '0' - '0' > 3) { break; } } if(j == bl) { break; } } res2 = i + bl; res = min(res1, res2); if(res > len) cout << res << endl; else cout << len << endl; memset(bottom, 0, sizeof(bottom)); memset(top, 0, sizeof(top)); } return 0; }
相关文章推荐
- select绑定json数组对象 asp.net
- HDU 5446 CRT+Lucas+快速乘
- 蓝懿iOS 内容和心得
- linux支持中文
- JavaScript-js中函数问题
- rtsp2rtmp程序,从rtsp摄像机获取流,转换为rtmp push到FMS
- input/select/textarea标签的readonly效果实现
- C# 如何执行bat文件 传参数
- Android Studio 1.4 新特性介绍
- codeforces #324 div 2 A. Olesya and Rodion
- 每天要更新了
- ElasticSearch的基本用法与集群搭建
- git学习笔记之一
- xcode-select: error: tool ‘xcodebuild(转)
- Linux下搭建Apache环境,执行Apache ab进行网站压力测试
- UITextField的leftView和rightView属性
- Part 97 Performance of a multithreaded program
- c# 程序后台运行
- 为何使用dynamic_cast转换类指针时,需要虚函数?
- ubuntu 14.04 glade 联编,(超简单的模型),哪些问题,怎么解决?