心如止水
Je n'ai pas le temps
posts - 400,comments - 130,trackbacks - 0
采用很暴力的办法即可。
以下是我的代码:
#include<algorithm>
#include
<cstdio>
using namespace std;
const int kMaxn(87);

struct Type
{
    
int a_,b_,c_,s_;
};

int main()
{
    
/*
    freopen("data.in","r",stdin);
    freopen("data.out","w",stdout);
    //
*/

    
int T(0),n;
    
while(scanf("%d",&n)==1 && n)
    {
        Type r[kMaxn];
        
for(int i=1;i<=n;i++)
            scanf(
"%d%d%d%d",&r[i].a_,&r[i].b_,&r[i].c_,&r[i].s_);

        
int ans(-1);
        
for(int i=1;i<=n;i++)
            
for(int j=1;j<=n;j++)
                
for(int k=1;k<=n;k++)
                {
                    
bool used[10]={false};
                    used[r[i].a_]
=true;
                    used[r[i].b_]
=true;
                    used[r[i].c_]
=true;
                    used[r[j].a_]
=true;
                    used[r[j].b_]
=true;
                    used[r[j].c_]
=true;
                    used[r[k].a_]
=true;
                    used[r[k].b_]
=true;
                    used[r[k].c_]
=true;

                    
bool success(true);
                    
for(int l=1;l<=9;l++)
                        
if(!used[l])
                        {
                            success
=false;
                            
break;
                        }

                    
if(!success)
                        
continue;

                    ans
=max(ans,r[i].s_+r[j].s_+r[k].s_);
                }

        T
++;
        printf(
"Case %d: %d\n",T,ans);
    }

    
return 0;
}
posted on 2011-04-19 15:31 lee1r 阅读(245) 评论(0)  编辑 收藏 引用 所属分类: 题目分类:搜索

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理