zoukankan      html  css  js  c++  java
  • paimai

    #include<iostream>
    
    int data[8][4]={0};
    
    int b[3][3]={1,1,0,
    
                 1,0,1,
    
                 0,1,1};
    
    int sp[17]={0};
    
    int n,m;   //n是拍卖品 m是人数
    
    int max=0;
    
    void dfs(int step,int mon)
    
    {   
    
        if(step==m)
    
        {
    
            if(mon>max)
    
            {
    
               max=mon;
    
            }
    
            return;
    
        }
    
        for(int i=0;i<3;i++)   //0不拍 1拍两个 2 拍三个
    
        {
    
            if(i==0)
    
            {
    
                dfs(step+1,mon);
    
            }
    
            if(i==1)
    
            {
    
                for(int j=0;j<3;j++)
    
                {
    
                    if(j==0)
    
                    {
    
                        if(sp[data[step][0]]==0&&sp[data[step][1]]==0)
    
                        {
    
                            sp[data[step][0]]=1;
    
                            sp[data[step][1]]=1;
    
                            dfs(step+1,mon+data[step][3]*2);
    
                            sp[data[step][0]]=0;
    
                            sp[data[step][1]]=0;
    
     
    
                        }
    
                    }
    
                    if(j==1)
    
                    {
    
                        if(sp[data[step][1]]==0&&sp[data[step][2]]==0)
    
                        {
    
                            sp[data[step][1]]=1;
    
                            sp[data[step][2]]=1;
    
                            dfs(step+1,mon+data[step][3]*2);
    
                            sp[data[step][1]]=0;
    
                            sp[data[step][2]]=0;
    
     
    
                        }
    
                    }
    
                    if(j==2)
    
                    {
    
                        if(sp[data[step][0]]==0&&sp[data[step][2]]==0)
    
                        {
    
                            sp[data[step][0]]=1;
    
                            sp[data[step][2]]=1;
    
                            dfs(step+1,mon+data[step][3]*2);
    
                            sp[data[step][0]]=0;
    
                            sp[data[step][2]]=0;
    
     
    
                         }
    
     
    
                }
    
            }
    
            }
    
            if(i==2)
    
            {
    
                if(sp[data[step][0]]==0&&sp[data[step][1]]==0&&sp[data[step][2]]==0)
    
                {
    
                    sp[data[step][0]]=1;
    
                    sp[data[step][1]]=1;
    
                    sp[data[step][2]]=1;
    
                    dfs(step+1,mon+data[step][3]*3);
    
                    sp[data[step][0]]=0;
    
                    sp[data[step][1]]=0;
    
                    sp[data[step][2]]=0;
    
     
    
                }
    
     
    
            }
    
        }
    
     
    
    }
    
     
    
    int main()
    
    {  
    
        freopen("input.txt","r",stdin);
    
        scanf("%d%d",&n,&m); //m 人数
    
        for(int i=0;i<m;i++)
    
        { 
    
            for(int j=0;j<4;j++)
    
            {
    
            scanf("%d",&data[i][j]);
    
            }
    
     
    
        }
    
        for(int i=0;i<m;i++)
    
        { 
    
            for(int j=0;j<4;j++)
    
            {
    
            printf("%d ",data[i][j]);
    
            }
    
     
    
            printf("
    ");
    
        }
    
     
    
        dfs(0,0);
    
        printf("%d",max);
    
     
    
     
    
    }
    
  • 相关阅读:
    使用javaDate类代数据仓库维度表
    Hermes和开源Solr、ElasticSearch 不同
    MapReduce 异常 LongWritable cannot be cast to Text
    吐槽CSDN编辑
    Codeforces 452A Eevee
    看不清楚未来,请做好如今
    JDBC数据库连接
    mixpanel实验教程(2)
    使用jquery+一般处理程序异步载入信息
    Eclipse中的Maven项目报Unbound classpath variable错误
  • 原文地址:https://www.cnblogs.com/452035305qq/p/6474444.html
Copyright © 2011-2022 走看看