zoukankan      html  css  js  c++  java
  • C

    题目链接:http://acm.hust.edu.cn/vjudge/contest/126708#problem/C

    就是求有多少个相同的元素:

    代码如下:

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    using namespace std;
    int s[1005][1005];
    int main()
    {
         char a[1000],b[1000];
         while(scanf("%s%s",a,b)==2)
         {
           memset(s,0,sizeof(s));
           for(int i=1;i<=strlen(a);i++)
                   for(int j=1;j<=strlen(b);j++)
                   {
                        if(a[i-1]==b[j-1])
                             s[i][j]=s[i-1][j-1]+1;
                        else s[i][j]=max(s[i-1][j],s[i][j-1]);
                   }
                   printf("%d ",s[strlen(a)][strlen(b)]);
         }
         return 0;
    }

  • 相关阅读:
    hh
    SDUT 3923 打字
    最短路
    阶乘后面0的个数(51Nod 1003)
    大数加法
    Biorhythms(中国剩余定理)
    usaco-5.1-theme-passed
    usaco-5.1-starry-passed
    usaco-5.1-fc-passed
    usaco-4.4-frameup-passed
  • 原文地址:https://www.cnblogs.com/441179572qqcom/p/5767306.html
Copyright © 2011-2022 走看看