Follows 10405.c (Total 37 lines):

/* @JUDGE_ID:4461XX 10405 C */
/* A */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

#define MAXLENGTH 1000

char str1[MAXLENGTH+1] , str2[MAXLENGTH+1] ;

int input( void )
{
	if( gets( str1 ) ) gets( str2 ) ;
	else return 0 ;

	return 1 ;
}
int LCS( void )
{
	int t[MAXLENGTH+1][MAXLENGTH+1] , i , j ;
	memset( t , 0 , sizeof( t ) ) ;

	for( i=1 ; i<=strlen( str1 ) ; ++i )
		for( j=1 ; j<=strlen( str2 ) ; ++j )
			if( str1[i-1]==str2[j-1] )
				t[i][j] = t[i-1][j-1]+1 ;
			else
				t[i][j] = t[i-1][j]>t[i][j-1]?t[i-1][j]:t[i][j-1] ;
				
	return t[strlen( str1 )][strlen( str2 )] ;
}
int main( void )
{
	while( input() ) printf( "%d\n" , LCS() ) ;

	return 0 ;
}

Back to statistics
Ya-Lin Huang (C)
huangyl@gmail.com