Follows 10069.c (Total 69 lines):

/* @JUDGE_ID:4461XX 10069 C */
/* A */
#include<stdio.h>
#include<string.h>
#define Lenth_mo 10000
#define Lenth_ch 100
#define Size 12 
#define Limit 1000000000

char mother[Lenth_mo+1] , child[Lenth_ch+1] ;
int table[Lenth_ch+1][Size] ; /* big number */
void initial( void )
{
	int i , j ;

	for( i=0 ; i<=strlen( child ) ; i++ )
		for( j=0 ; j<Size ; j++ ) table[i][j] = 0 ;
	table[0][0] = 1 ;
}
void Add( int j )
{
	int i ;

	for( i=0 ; i<Size ; i++ ){
		table[j][i] += table[j-1][i] ;
		if( table[j][i]>=Limit ){
			table[j][i+1] += table[j][i]/Limit ;
			table[j][i] %= Limit ;
		}
	}
}
void make_table( void )
{
	int i , j , len ;
	
	initial() ;
	len = strlen( child ) ;
	for( i=0 ; mother[i] ; i++ )
		for( j=len-1 ; j>=0 ; j-- )
			if( mother[i]==child[j] )
				Add( j+1 ) ;
}
void print( void )
{
	int i , len ;

	len = strlen( child ) ;
	for( i=Size-1 ; i>=0 ; i-- )
		if( table[len][i] ) break ;
	printf( "%d" , table[len][i] ) ;
	for( i-- ; i>=0 ; i-- )
		printf( "%9d" , table[len][i] ) ;
	putchar( '\n' ) ;
}
int main( void )
{
	int n ;

	scanf( "%d" , &n ) ;
	for( ; n ; n-- ){
		scanf( "%s" , mother ) ;
		scanf( "%s" , child ) ;
		make_table() ;
		print() ;
	}
	
	return 0 ;
}
/* @END_OF_SOURCE_CODE */

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