码迷,mamicode.com
首页 > 其他好文 > 详细

字符串模拟赛T3

时间:2016-07-20 21:11:35      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

只看我的做法就够了

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
const int maxn = 1005;
int n,m,ans;
char a[maxn],b[maxn];
int main(){
    cin>>a>>b;
    n = strlen(a);
    m = strlen(b);
    int l,r,tmp;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < m;j++){
            tmp = 0;
            for(int k = 1;i + k -1 < n && j + k -1 < m;k++){
                if(a[i+k-1] == 1 && b[j+k-1] == 1) tmp++;
            }
            if(ans < tmp) ans = tmp;
        }
    }
    cout<<ans;
    return 0;
}

 

字符串模拟赛T3

标签:

原文地址:http://www.cnblogs.com/hyfer/p/5689481.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!