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);
    
     
    
     
    
    }
    
  • 相关阅读:
    解决验证码问题
    python中的偏函数partial
    Python 数据表orm设计
    参悟yield 和yield from (加精)
    numpy基础
    JS中的面向对象
    pandas使用教程
    一次tornado建站项目分享
    django 一对一, 一对多,多对多的领悟
    三维向量类
  • 原文地址:https://www.cnblogs.com/452035305qq/p/6474444.html
Copyright © 2011-2022 走看看