字符串模拟赛T3

只看我的做法就够了

#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;
}

 

posted @ 2016-07-20 19:28  ACforever  阅读(189)  评论(0编辑  收藏  举报