Follows 10066.c (Total 42 lines):

/* @JUDGE_ID:4461XX 10066 C */
/* A */
#include<stdio.h>
int map[101][101] , a1[101] , a2[101] ;
void initial_map( void )
{
	int i ;
	for( i=0 ; i<101 ; i++ )
		map[0][i] = map[i][0] = 0 ;
}
int Max( int a , int b )
{
	if( a<b ) return b ;
	else return a ;
}
void lcs( int n1 , int n2 )
{
	int i , j ;
	for( i=1 ; i<=n1 ; i++ )
		for( j=1 ; j<=n2 ; j++ )
			if( a1[i]==a2[j] ) map[i][j] = map[i-1][j-1] + 1 ;
			else map[i][j] = Max( map[i][j-1] , map[i-1][j] ) ;
}
void main( void )
{
	int time , n1 , n2 , i ;
	for( time=1 ; ; time++ ){
		scanf( "%d %d" , &n1 , &n2 ) ;
		if( !n1 && !n2 ) break ;

		initial_map() ;

		for( i=1 ; i<=n1 ; i++ ) scanf( "%d" , &a1[i] ) ;
		for( i=1 ; i<=n2 ; i++ ) scanf( "%d" , &a2[i] ) ;

		lcs( n1 , n2 ) ;

		printf( "Twin Towers #%d\n" , time ) ;
		printf( "Number of Tiles : %d\n\n" , map[n1][n2] ) ;
	}
}
/* @END_OF_SOURCE_CODE */

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