| ÍøÕ¾Ê×Ò³ | Òµ½çÐÂÎÅ | С×é | Íþ¿Í | È˲Š| ÏÂÔØƵµÀ | ²©¿Í | ´úÂëÌù | ÔÚÏß±à³Ì | ±à³ÌÂÛ̳
»¶Ó­¼ÓÈëÎÒÃÇ£¬Ò»Í¬Çд輼Êõ
Óû§Ãû£º   
 
ÃÜ¡¡Â룺  
¹²ÓÐ 479 È˹Ø×¢¹ý±¾Ìû
±êÌ⣺ΪʲôһֱÊÇWrong Answer£¿ÄÄÀïµÄ´úÂëÓÐÎÊÌ⣿
Ö»¿´Â¥Ö÷ ¼ÓÈëÊÕ²Ø
glglzb
Rank: 2
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º47
ר¼Ò·Ö£º22
×¢¡¡²á£º2011-10-12
½áÌûÂÊ£º93.33%
ÊÕ²Ø
ÒѽáÌù¡Ì  ÎÊÌâµãÊý£º20 »Ø¸´´ÎÊý£º2 
ΪʲôһֱÊÇWrong Answer£¿ÄÄÀïµÄ´úÂëÓÐÎÊÌ⣿
1007. Common Subsequence
×ÜÌá½»ÊýÁ¿£º    522    ͨ¹ýÊýÁ¿£º    90
           
ʱ¼äÏÞÖÆ£º1Ãë    ÄÚ´æÏÞÖÆ£º256Õ×
ÌâÄ¿ÃèÊö
 A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm>, another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a strictly increasing sequence(ÑϸñµÝÔö) <i1, i2, ..., ik> of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = <a, b, f, c> is a subsequence of X = <a, b, c, f, b, c> with index sequence <1, 2, 4, 6>. Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y.

ÊäÈë¸ñʽ
 The first line is a positive integer N (1 <= N <= 10000), giving the number of the test cases.
Each test case contains two strings representing the given sequences. The sequences are separated by any number of white spaces. Both the length of the sequences are less than 15.

Êä³ö¸ñʽ
 For each test case, the program prints the length of the maximum-length common subsequence from the beginning of a separate line.

ÑùÀýÊäÈë
 ½«ÑùÀýÊäÈ븴ÖƵ½¼ôÌù°å
3
abcfbc  abfcab
programming  come
abcd  mnp
ÑùÀýÊä³ö
4
2
0
ÎÒµÄ×ö·¨ÊÇ£º
#include <string.h>
int main()
{
    int n,i,j,k,counter;
    char b[15], a[15];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        k=0;
        counter = 0;
        scanf("%s",b);
        scanf("%s",a);
        for(j=0;j<strlen(a);j++)
        {
            for(k;k<strlen(b);k++)
            {
                if(a[j] == b[k])
                {
                    counter++;
                    break;
                }
            }
        }
        printf("%d\n",counter);
    }
    return 0;

}
ËÑË÷¸ü¶àÏà¹ØÖ÷ÌâµÄÌû×Ó: possible¡¡elements¡¡ÄÚ´æ¡¡sequence¡¡
2012-06-03 18:52
glglzb
Rank: 2
µÈ¡¡¼¶£ºÂÛ̳ÓÎÃñ
Ìû¡¡×Ó£º47
ר¼Ò·Ö£º22
×¢¡¡²á£º2011-10-12
ÊÕ²Ø
µÃ·Ö:0 
»Ø¸´ 2Â¥ jokerskill
Õâ¸ö¡ª¡ªÖ»ºÃÕâÑùÁË    û°ì·¨°¡
2012-06-03 19:25
beyondyf
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
µÈ¡¡¼¶£º¹ó±ö
Íþ¡¡Íû£º103
Ìû¡¡×Ó£º3282
ר¼Ò·Ö£º12654
×¢¡¡²á£º2008-1-21
ÊÕ²Ø
µÃ·Ö:20 
×¹«¹²×ÓÐòÁУ¬¾­µäµÄDPÃüÌâ¡£»ù±¾ÉϽ²¶¯Ì¬¹æ»®Ê±±ØÈ»»áÌáµ½µÄÀýÌâ¡£

ÄãµÄ´úÂë¸úÕâ¸öÌâÄ¿·çÂíÅ£²»Ï༰£¬ÖØÐÂѧϰ¡£

Öؽ£Î޷棬´óÇɲ»¹¤
2012-06-03 20:09
¿ìËٻظ´£ºÎªÊ²Ã´Ò»Ö±ÊÇWrong Answer£¿ÄÄÀïµÄ´úÂëÓÐÎÊÌ⣿
Êý¾Ý¼ÓÔØÖÐ...
 
¡¡¡¡¡¡



¹ØÓÚÎÒÃÇ | ¹ã¸æºÏ×÷ | ±à³ÌÖйú | Çå³ýCookies | TOP | ÊÖ»ú°æ

±à³ÌÖйú °æȨËùÓУ¬²¢±£ÁôËùÓÐȨÀû¡£
Powered by Discuz, Processed in 0.011683 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved