zoukankan      html  css  js  c++  java
  • 【11.13 测试】String Master

     

    题解:仔细想一下就出来了恩。枚举s1中的 i 节点,枚举s2中的 j 节点。再枚举长度。

                计算有多少个不一样的字符,统计一下如果不超过最大修改次数就尝试更新ans,最后就出来啦。

    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cstdlib>
    #include<queue>
    #include<bits/stdc++.h>
    using namespace std;
    char s2[305],s1[303];
    int n,m;
    int f[302][302];
    int tmp,ans=0;
    void Yao_Chen_Lai_Le(){
        for(int i=1;i<=n;i++){
            for(int j=1;j<=n;j++){
                tmp=0;
                for(int l=1;l<=n;l++){
                    if(i+l-1>n) continue;
                    if(j+l-1>n) continue;
                    tmp+=(s1[i+l-1]!=s2[j+l-1]);     
                    if(tmp<=m) ans=max(ans,l);
                    else break;
                }
            }
        }
        printf("%d
    ",ans);
    }
    int main(){
        freopen("master.in","r",stdin);
        freopen("master.out","w",stdout);
        scanf("%d %d
    %s
    %s",&n,&m,s1+1,s2+1);
        Yao_Chen_Lai_Le();
        return 0;
    }
  • 相关阅读:
    面试准备
    session
    memcached优化方案实例
    MySQL用户管理
    MySQL事务
    Linux防火墙
    Linux权限体系
    Linux查看日志文件
    查看系统状态
    负载均衡(六)分表分库的负载均衡
  • 原文地址:https://www.cnblogs.com/wuhu-JJJ/p/11848683.html
Copyright © 2011-2022 走看看