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);
    
     
    
     
    
    }
    
  • 相关阅读:
    发布机制:功能开关发布
    发布机制:蛮力发布
    发布机制-滚动式发布:百科
    发布机制-灰度发布:百科
    发布机制:金丝雀发布
    发布机制-蓝绿发布:百科
    发布机制:百科
    服务安全-IAM:百科
    Workflow-产品:泛微工作流引擎
    android Fragment
  • 原文地址:https://www.cnblogs.com/452035305qq/p/6474444.html
Copyright © 2011-2022 走看看