委派任务

 

Time Limit: 1 Sec  Memory Limit: 128 MB

 

Submit: 3  Solved: 3

 

Description

某侦察队接到一项紧急任务,要求在A、B、C、D、E、F六个队员中尽可能多地挑若干人,但有以下限制条件: 
1)A和B两人中至少去一人; 
2)A和D不能一起去; 
3)A、E和F三人中要派两人去; 
4)B和C都去或都不去; 
5)C和D两人中去一个; 
6)若D不去,则E也不去。 
问应当让哪几个人去? 

Input

 

Output

要派出的人 
若有多个,按字母递增顺序排列,用逗号分开(含末尾逗号) 

Sample Input

 

Sample Output

A,B,C,F,

HINT

 

Source

 
 
#include<iostream>
#include<algorithm>
using namespace std;

void Add(int *a)
{
    a[6]++;
    for(int i=6;i>0;i--)
    {
       if(a[i]>1)
       {a[i]-=2;a[i-1]++;}    
    } 
}

int main()
{
    int a[7]={0},b[6]={0},k=0;
    
    for(int i=0;a[0]!=1;i++)
    {
    
        
        if(a[1]+a[2]>=1&&a[1]+a[4]!=2&&a[1]+a[5]+a[6]==2&&a[2]-a[3]==0&&a[3]+a[4]==1&&(a[4]==0&&a[5]==0||a[4]==1&&a[5]==1||a[4]==1&&a[5]==0))
        {
             for(int j=1;j<7;j++)
             {
                 if(a[j])
                 {cout<<(char)(j+'A'-1)<<",";}
             }
             
            
             

        }
        
        
        Add(a);
    }
    
    return 0;
}

 

posted @ 2017-03-17 15:04  dearvee  阅读(251)  评论(0)    收藏  举报