#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std ;
int num[6] ;
bool vis[6] ;
int n , Max ;
void dfs( int depth )
{
int i , j ;
if( depth == 4 )
{
int flag = 0 , FLAG = 0 ;
int sum = 0 ;
for( i = 1 ; i <= 5 ; i ++ )
{
if( vis[i] )
{
if( num[i] == -1 ) flag = 1 ;
else sum += num[i] ;
}
}
if( !flag && sum % 1024 == 0 ) flag = 1 ;
sum = 0 ;
for( i = 1 ; i <= 5 ; i ++ )
{
if( !vis[i] )
{
if( num[i] == -1 ) FLAG = 1 ;
else sum += num[i] ;
}
}
if( FLAG == 1 ) sum = 1024 ;
while( sum > 1024 ) sum -= 1024 ;
if( flag == 1 && sum > Max ) Max = sum ;
return ;
}
for( i = 1 ; i <= 5 ; i ++ )
{
if( !vis[i] )
{
vis[i] = 1 ;
dfs( depth + 1 ) ;
vis[i] = 0 ;
}
}
}
int main()
{
int i , j ;
while( scanf( "%d" , & n ) != EOF )
{
Max = 0 ;
memset( num , -1 , sizeof( num ) ) ;
memset( vis , 0 , sizeof( vis ) ) ;
for( i = 1 ; i <= n ; i ++ )
scanf( "%d" , & num[i] ) ;
dfs( 1 ) ;
printf( "%d\n" , Max ) ;
}
return 0 ;
}
这题是长春赛区的C题;
题意:好多,自己看吧,,
题解:水题,就是讨论一下