Follows 435.c (Total 50 lines):

/* @JUDGE_ID:4461XX 435 C */
/* A */
#include<stdio.h>
int ans[25000] , num[30] , sum , print_time ;
void print( int i )
{
	int j , add ;
	for( j=sum-num[i] , add=0 ; j<sum ; j++ )
		add += ans[j] ;
	printf( "party %d has power index %d\n" , print_time++ , add ) ;
}
void make_ans( int j , int i )
{
	int m , n ;
	int max=0 ;
	ans[0] = 1 ;
	for( m=1 ; m<=sum ; m++ ) ans[m] = 0 ;
	for( m=0 ; m<i ; m++ )
		if( m!=j )
			for( n=max ; n>=0 ; n-- )
				if( ans[n] && n+num[m]<=sum ){
					ans[n+num[m]] += ans[n] ;
					if( n+num[m] > max ) max = n+num[m] ;
				}
}
int devide( int m )
{
	if( m%2 ) return m / 2 + 1 ;
	return m / 2 ;
}
void main( void )
{
	int i , j , k , n ;
/*	freopen( "C:\\windows\\desktop\\435.in" , "r" , stdin ) ;*/
	scanf( "%d\n" , &n ) ;
	for( k=0 ; k<n ; k++ ){
		print_time = 1 ;
		scanf( "%d" , &j ) ;
		for( i=0 , sum=0 ; i<j ; i++ ){
			scanf( "%d" , &num[i] ) ;
			sum += num[i] ;
		}
		sum = devide( sum ) ;
		for( j=0 ; j<i ; j++ ){
			make_ans( j , i ) ;
			print( j ) ;
		}
		putchar( '\n' ) ;
	}
}

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