Follows 119.c (Total 41 lines):

/* @JUDGE_ID:4461XX 119 C */
/* A */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
char a[10][13] ;
int num[10] , n ;
void check( void )
{
	char top[10000] , *p ; int i , money , person ;
	gets( top ) ;
	p = strtok( top , " " ) ;
	for( i=0 ; i<n ; i++ )
		if( strcmp( p , a[i] )==0 ) break ;
	p = strtok( NULL , " " ) ;
	money = atoi( p ) ;
	p = strtok( NULL , " " ) ;
	person = atoi( p ) ;
	if( person!=0 )
	{
		num[i] += money % person ;
		num[i] -= money ;
		money = ( money - ( money % person ) ) / person ;
		for( p=strtok( NULL , " " ) ; p!=0 ; p=strtok( NULL , " " ) )
			for( i=0 ; i<n ; i++ )
				if( strcmp( p , a[i] )==0 ) num[i] += money ;
	}
}
void main( void )
{
	int i ;
	while( scanf( "%d\n" , &n )==1 )
	{
		for( i=0 ; i<n ; i++ ) num[i] = 0 ;
		for( i=0 ; i<n ; i++ ) scanf( "%s" , &a[i] ) ;
		scanf( "\n" ) ;
		for( i=0 ; i<n ; i++ ) check( ) ;
		for( i=0 ; i<n ; i++ ) printf( "%s %d\n" , a[i] , num[i] ) ;
		printf( "\n" ) ;
	}
}

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